#abc345g. G - Sugoroku 5

G - Sugoroku 5

Score: 675675 points

问题陈述

有一个棋盘游戏,共有 N+1N+1 个方格:方格 00,方格 11\dots,方格 NN。 你有一枚骰子,它掷出的数字是 11KK(包括 11KK),每个结果出现的概率相等。 你从方格 00 开始。重复以下操作,直到到达方格 NN

  • 掷骰子。设 xx 为当前方格,yy 为掷出的数字,然后移动到方格 min(N,x+y)\min(N, x + y)

PiP_i 为在恰好 ii 次操作后到达方格 NN 的概率。计算 P1,P2,,PNP_1, P_2, \dots, P_N998244353998244353

998244353998244353 模下的概率是什么?可以证明,所求的概率总是有理数。在这个问题的约束条件下,也可以证明,当使用两个互质整数 PPQQ 表示这些值时,存在唯一的整数 RR 满足 R×QP(mod998244353)R \times Q \equiv P\pmod{998244353}0R<9982443530 \leq R < 998244353。找到这个 RR

以上为大语言模型 kimi 翻译,仅供参考。

Problem Statement

There is a board game with N+1N+1 squares: square 00, square 11, \dots, square NN.
You have a die (dice) that rolls an integer between 11 and KK, inclusive, with equal probability for each outcome.
You start on square 00. You repeat the following operation until you reach square NN:

  • Roll the dice. Let xx be the current square and yy be the rolled number, then move to square min(N,x+y)\min(N, x + y).

Let PiP_i be the probability of reaching square NN after exactly ii operations. Calculate P1,P2,,PNP_1, P_2, \dots, P_N modulo 998244353998244353.

What is probability modulo 998244353998244353? It can be proved that the sought probabilities will always be rational numbers. Under the constraints of this problem, it can also be proved that when expressing the values as PQ\frac{P}{Q} using two coprime integers PP and QQ, there is exactly one integer RR satisfying R×QP(mod998244353)R \times Q \equiv P\pmod{998244353} and 0R<9982443530 \leq R < 998244353. Find this RR.

Constraints

  • 1KN2×1051 \leq K \leq N \leq 2 \times 10^5
  • NN and KK are integers.

Input

The input is given from Standard Input in the following format:

NN KK

Output

Print NN lines. The ii-th line should contain PiP_i modulo 998244353998244353.

Sample Input 1

3 2

Sample Output 1

0
249561089
748683265

For example, you reach square NN after exactly two operations when the die rolls the following numbers:

  • A 11 on the first operation, and a 22 on the second operation.
  • A 22 on the first operation, and a 11 on the second operation.
  • A 22 on the first operation, and a 22 on the second operation.

Therefore, $P_2 = \left( \frac{1}{2} \times \frac{1}{2} \right) \times 3 = \frac{3}{4}$. We have 249561089×43(mod998244353)249561089 \times 4 \equiv 3 \pmod{998244353}, so print 249561089249561089 for P2P_2.

Sample Input 2

5 5

Sample Output 2

598946612
479157290
463185380
682000542
771443236

Sample Input 3

10 6

Sample Output 3

0
166374059
207967574
610038216
177927813
630578223
902091444
412046453
481340945
404612686

update @ 2024/5/16 17:17:27