#P6561. Non-adjacent Memory Selection

    ID: 19773 Type: Default 1000ms 256MiB

Non-adjacent Memory Selection

Non-adjacent Memory Selection

In her dream, there are \(2m\) memory fragments numbered \(1,2,\ldots,2m\). The odd-indexed fragments are white and the even-indexed fragments are black. She wants to form two memories by selecting exactly \(a\) white fragments (from the odd-indexed ones) and exactly \(b\) black fragments (from the even-indexed ones). However, the chosen fragments must not be adjacent; that is, no two selected fragments have consecutive numbers.

This condition is equivalent to forbidding the selection of both fragments from any pair \((2i-1,2i)\) for \(i=1,2,\ldots,m\). In each such pair, at most one fragment can be chosen. Therefore, if we denote the number of pairs chosen with an odd fragment by \(x\) and with an even fragment by \(y\), we must have \(x=a\), \(y=b\) and clearly \(a+b\le m\). The answer is then given by:

[ \text{Answer} = \begin{cases} \displaystyle \binom{m}{a}\binom{m-a}{b} & \text{if } a+b \le m, \ 0 & \text{otherwise.} \end{cases} ]

Since the answer can be very large, output the result modulo \(998244353\).

inputFormat

The input consists of a single line containing three space-separated integers: \(m\), \(a\), and \(b\).

outputFormat

Output a single integer: the number of valid ways to choose the fragments modulo \(998244353\).

sample

2 1 1
2