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.
InputThe first line contains integers $$$R$$$ ($$$1 \leq R \leq 10^{18}$$$) and $$$B$$$ ($$$1 \leq B \leq 10^6$$$).
OutputPrint the answer.
ExamplesInput10 3Output
8390Input
3 10Output
0Input
100 10Output
801171977Input
999999999999999999 999999Output
448294209