/
Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 3 点
問題文
2 次元座標上の (0, 0) に駒が置かれています。
あなたは次の一連の操作を 0 回以上自由な回数行うことができます。
- まず、0 \leq a \leq 1 かつ 0 \leq b を満たす整数対 (a, b) を選ぶ。ただし (a, b) = (0, 0) は選ぶことが出来ない。
- そして、駒が今置かれている座標を (x, y) として、駒を (x+a, y+b) に移動させる。
操作を全て終了した後に駒が (N, M) に置かれた状態になるような操作列の個数を 998244353 で割った余りを求めてください。
制約
- 1 \leq N \leq 2 \times 10^5
- 1 \leq M \leq 2 \times 10^5
- 入力される値は全て整数
入力
入力は以下の形式で標準入力から与えられる。
N M
出力
答えを出力せよ。
入力例 1
2 1
出力例 1
5
条件を満たす各操作列について、操作で経由するマスをそれぞれ列挙すると次の 5 通りになります。
- (0, 0) \to (0, 1) \to (1, 1) \to (2, 1)
- (0, 0) \to (1, 0) \to (1, 1) \to (2, 1)
- (0, 0) \to (1, 0) \to (2, 0) \to (2, 1)
- (0, 0) \to (1, 0) \to (2, 1)
- (0, 0) \to (1, 1) \to (2, 1)
入力例 2
12345 67890
出力例 2
824829859
Score: 3 points
Problem Statement
On a 2D coordinate plane, a piece is placed at (0, 0).
You may perform the following operation any number of times (including zero):
- Choose an integer pair (a, b) such that 0 \leq a \leq 1, 0 \leq b, and (a, b) \neq (0, 0).
- If the current position of the piece is (x, y), move it to (x+a, y+b).
Find the number of operation sequences that result in the piece being at (N, M) after all operations, and output the answer modulo 998244353.
Constraints
- 1 \leq N \leq 2 \times 10^5
- 1 \leq M \leq 2 \times 10^5
- All input values are integers
Input
The input is given from standard input in the following format:
N M
Output
Print the answer.
Sample Input 1
2 1
Sample Output 1
5
For each valid operation sequence, the visited coordinates are as follows (5 possibilities):
- (0, 0) \to (0, 1) \to (1, 1) \to (2, 1)
- (0, 0) \to (1, 0) \to (1, 1) \to (2, 1)
- (0, 0) \to (1, 0) \to (2, 0) \to (2, 1)
- (0, 0) \to (1, 0) \to (2, 1)
- (0, 0) \to (1, 1) \to (2, 1)
Sample Input 2
12345 67890
Sample Output 2
824829859