CodeTON Round 8 (Div. 1 + Div. 2, Rated, Prizes!)
E
Farm Game
Codeforces
2300
原题
← DF →
翻译中…

Farmer Nhoj has brought his cows over to Farmer John's farm to play a game! FJ's farm can be modeled by a number line with walls at points $0$ and $l + 1$. On the farm, there are $2n$ cows, with $n$ of the cows belonging to FJ and the other $n$ belonging to FN. They place each of their cows at a distinct point, and no two FJ's cows nor FN's cows are adjacent. Two cows are adjacent if there are no other cows between them.

翻译中…

Formally, if $a_1, a_2, \ldots, a_n$ represents the positions of FJ's cows and $b_1, b_2, \ldots, b_n$ represents the positions of FN's cows, then either $0 \lt a_1 \lt b_1 \lt a_2 \lt b_2 \lt \ldots \lt a_n \lt b_n \lt l + 1$ or $0 \lt b_1 \lt a_1 \lt b_2 \lt a_2 \lt \ldots \lt b_n \lt a_n \lt l + 1$.

翻译中…

In one move, a farmer chooses a number $k$ $(1 \leq k \leq n)$ and a direction (left or right). Then, that farmer chooses $k$ of his cows and moves them one position towards the chosen direction. A farmer cannot move any of his cows onto the walls or onto another farmer's cow. If a farmer cannot move any cows, then that farmer loses. FJ starts the game, making the first turn.

翻译中…

Given $l$ and $n$, find the number of possible game configurations for Farmer John to win if both farmers play optimally. It may be the case that the game will continue indefinitely, in which no farmer wins. A configuration is different from another if there is any $i$ such that $a_i$ or $b_i$ is different. Output the answer modulo $998\,244\,353$.

翻译中…

Input

翻译中…

The first line contains $t$ ($1 \leq t \leq 10^4$) — the number of test cases.

翻译中…

Each test case contains two integers $l$ and $n$ ($2 \leq l \leq 10^6, 1 \leq n \leq \lfloor \frac{l}{2} \rfloor$) — the length of the number line and the number of cows each farmer will place.

翻译中…

It is guaranteed the sum of $l$ over all test cases does not exceed $10^6$.

翻译中…

Output

翻译中…

For each test case output an integer: the number of game configurations where Farmer John wins if both farmers play optimally, modulo $998\,244\,353$.

翻译中…

Note

翻译中…

Let J denote FJ's cow, N denote FN's cow, and _ denote an empty space.

翻译中…

For the first test case, the two possible configurations are JN or NJ. In both cases, since FJ makes the first turn and cannot make any moves, he cannot win.

翻译中…

For the second case there are two possible configurations for FJ to win: N_J and J_N.

翻译中…

样例

Input #1
3
2 1
3 1
420 69
Output #1
0
2
870279412
InputCopy OutputCopy
题目信息
题号
1942E
时间限制
2 s
内存限制
256 MB
标签
组合数学
博弈论

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。