题目描述
There are N chits, out of which, A chits have 1 written on them and B (A+B = N) chits have 0 written on them.
Chef and Chefina are taking alternate turns. They both have a personal score which is initially set to 0. Chef starts first. On their turn, a player will:
Pick a random chit among the available chits;
Add the number written on the chit to their personal score;
Remove the chit that was picked.
Determine the [expected] score of Chef after all chits have been picked.
The expected score can be written in the form of $\frac{P}{Q}$ such that Q is not divisible by 998244353 and its guaranteed that for testcases that Q is not a multiple of 998244353. Output the value of $P \cdot Q^{-1} mod 998244353$.
------ Input Format ------
- The first line of input will contain a single integer T, denoting the number of test cases.
- Each test case consists of two integers A and B, the number of chits having 1 and 0 respectively.
------ Output Format ------
For each test case, output the expected score of Chef.
The expected score can be written in the form of $\frac{P}{Q}$. Output the value of $P \cdot Q^{-1} mod 998244353$.
------ Constraints ------
$1 ≤ T ≤ 1000$
$0 ≤ A, B ≤ 10^{9}$
$1 ≤ A+B ≤ 10^{9}$
----- Sample Input 1 ------
3
1 1
0 5
3 4
----- Sample Output 1 ------
499122177
0
285212674
----- explanation 1 ------
Test case $1$: There is one chit with $1$ written on it and $1$ chit with $0$ written on it. Consider all possible cases as follows:
- Chef picks the chit with $1$ on his turn. Thus, Chefina picks the chit with $0$. The final score of Chef is $1$.
- Chef picks the chit with $0$ on his turn. Thus, Chefina picks the chit with $1$. The final score of Chef is $0$.
The expected score of Chef is $\frac {1}{2} \cdot 1 + \frac {1}{2} \cdot 0 = \frac {1}{2}$. This is equivalent to $1\cdot 2^{-1} = 499122177$.
Test case $2$: All chits have $0$ written on them. Thus, in any case, the final score would be $0$. Thus, the expected score of Chef is also $0$.
输入格式
见题面
输出格式
见题面