

Time Limit: 2 sec / Memory Limit: 1024 MiB
配点 : 900 点
問題文
周長 L の円があり,円周上に L 人の人が等間隔に立っています. 彼らを時計回りに人 0,1,\cdots,L-1 と呼ぶことにします. この L 人から N 人を選ぶことを考えます. ある選び方のコストを以下のように定義します.
- N 人から 2 人組を選ぶすべての方法について,一方の人が他方の人の位置まで (円周上のみを通って) 移動するときの最小の移動距離を求める. これらの距離の最大値がコストとなる.
すべての選び方に対するコストの総和を 998244353 で割ったあまりを求めてください.
制約
- 2 \leq N \leq L \leq 10^6
- 入力される値はすべて整数
入力
入力は以下の形式で標準入力から与えられる.
L N
出力
答えを出力せよ.
入力例 1
4 2
出力例 1
8
選んだ N 人と,それに対応するコストは以下の通りです.
- (0,1): コスト 1
- (0,2): コスト 2
- (0,3): コスト 1
- (1,2): コスト 1
- (1,3): コスト 2
- (2,3): コスト 1
これらの総和である 8 が答えになります.
入力例 2
5 5
出力例 2
2
全員を選ぶしかありません. このときのコストは 2 です.
入力例 3
13 5
出力例 3
7618
入力例 4
1000000 100000
出力例 4
664396470
Score : 900 points
Problem Statement
There is a circle with circumference L, and L people are standing equally spaced along the circumference. They are labeled as person 0, 1, \cdots, L-1 in clockwise order. Consider choosing N from these L people. The cost of a choice is defined as follows.
- For every pair of persons among the N chosen people, find the minimum distance one person has to move along the circumference to reach the other person's position. The maximum value among these distances is the cost.
Find the sum of costs over all possible choices, modulo 998244353.
Constraints
- 2 \leq N \leq L \leq 10^6
- All input values are integers.
Input
The input is given from Standard Input in the following format:
L N
Output
Print the answer.
Sample Input 1
4 2
Sample Output 1
8
The choices of N people and their corresponding costs are as follows:
- (0,1): cost 1
- (0,2): cost 2
- (0,3): cost 1
- (1,2): cost 1
- (1,3): cost 2
- (2,3): cost 1
The sum of these costs, 8, is the answer.
Sample Input 2
5 5
Sample Output 2
2
We can only choose all of them. In this case, the cost is 2.
Sample Input 3
13 5
Sample Output 3
7618
Sample Input 4
1000000 100000
Sample Output 4
664396470