Logo
(追記) (追記ここまで)

21267번 - Count Min Ratio 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
4 초 1024 MB2821960.000%

문제

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.

입력

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

출력

Print the answer.

제한

예제 입력 1

10 3

예제 출력 1

8390

예제 입력 2

3 10

예제 출력 2

0

예제 입력 3

100 10

예제 출력 3

801171977

예제 입력 4

999999999999999999 999999

예제 출력 4

448294209

힌트

출처

Contest > Open Cup > 2020/2021 Season > Stage 14: Grand Prix of Tokyo C번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /