408065: GYM102978 C Count Min Ratio

Memory Limit:1024 MB Time Limit:4 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

C. Count Min Ratiotime limit per test4 secondsmemory limit per test1024 megabytesinputstandard inputoutputstandard output

You have $$$R$$$ red balls, $$$B$$$ blue balls, and one green ball. You are going to arrange the balls in a row. The score of an arrangement is defined as follows:

  • Let $$$l_{\mathrm{R}},l_{\mathrm{B}},r_{\mathrm{R}},r_{\mathrm{B}}$$$ be the number of red/blue balls to the left/right of the green ball, respectively. Then, the score is the maximum integer $$$x$$$ such that $$$l_{\mathrm{B}} \times x \leq l_{\mathrm{R}}$$$ and $$$r_{\mathrm{B}} \times x \leq r_{\mathrm{R}}$$$.

Find the sum of scores of all possible arrangements, modulo $$$998244353$$$. Note that balls of the same color cannot be distinguished, thus two arrangements are considered different if and only if there is such an $$$i$$$ that the color of the $$$i$$$-th ball in the first arrangement differs from that of the second.

Input

The first line contains integers $$$R$$$ ($$$1 \leq R \leq 10^{18}$$$) and $$$B$$$ ($$$1 \leq B \leq 10^6$$$).

Output

Print the answer.

ExamplesInput
10 3
Output
8390
Input
3 10
Output
0
Input
100 10
Output
801171977
Input
999999999999999999 999999
Output
448294209

加入题单

算法标签: