#abc275e. E - Sugoroku 4

E - Sugoroku 4

Score : 500500 points

问题描述

Takahashi 正在玩一款名为 sugoroku 的桌面游戏。

棋盘上有 N+1N+1 个格子,编号从 00NN。Takahashi 从第 00 号格子出发,目标是到达第 NN 号格子。

游戏中使用了一个轮盘,上面有 MM 个从 11MM 的数字,每个数字出现的概率相等。Takahashi转动轮盘,并按照轮盘指示的数字移动相应的格子数。如果这将导致他超过第 NN 号格子,则他在第 NN 号格子处掉头,并按超出的格子数返回。

例如,假设 N=4N=4 并且 Takahashi 在第 33 号格子上。如果轮盘显示数字 44,则超过第 44 格子的格子数为 3+44=33+4-4=3。因此,他会从第 44 格子向回走三个格子,最终到达第 11 格子。

当 Takahashi 到达第 NN 号格子时,他就赢了,游戏结束。

计算当 Takahashi 最多可以转轮盘 KK 次时,他获胜的概率对 998244353998244353 取模的结果。

如何打印概率对 998244353998244353 取模的结果

可以证明所求概率始终是一个有理数。此外,在本题的约束条件下,当所求概率表示为不可约分数 yx\frac{y}{x} 时,保证 xx 不被 998244353998244353 整除。

此时存在一个唯一的整数 zz,满足 0z9982443520 \leq z \leq 998244352 以及 xzy(mod998244353)xz \equiv y \pmod{998244353}。请输出这个 zz

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

Takahashi is playing sugoroku, a board game.

The board has N+1N+1 squares, numbered 00 to NN. Takahashi starts at square 00 and goes for square NN.

The game uses a roulette wheel with MM numbers from 11 to MM that appear with equal probability. Takahashi spins the wheel and moves by the number of squares indicated by the wheel. If this would send him beyond square NN, he turns around at square NN and goes back by the excessive number of squares.

For instance, assume that N=4N=4 and Takahashi is at square 33. If the wheel shows 44, the excessive number of squares beyond square 44 is 3+44=33+4-4=3. Thus, he goes back by three squares from square 44 and arrives at square 11.

When Takahashi arrives at square NN, he wins and the game ends.

Find the probability, modulo 998244353998244353, that Takahashi wins when he may spin the wheel at most KK times.

How to print a probability modulo 998244353998244353

It can be proved that the sought probability is always a rational number. Additionally, under the Constraints of this problem, when the sought probability is represented as an irreducible fraction yx\frac{y}{x}, it is guaranteed that xx is not divisible by 998244353998244353.

Here, there is a unique integer zz between 00 and 998244352998244352 such that xzy(mod998244353)xz \equiv y \pmod{998244353}. Print this zz.

Constraints

  • MN1000M \leq N \leq 1000
  • 1M101 \leq M \leq 10
  • 1K10001 \leq K \leq 1000
  • All values in the input are integers.

Input

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

NN MM KK

Output

Print the answer.

Sample Input 1

2 2 1

Sample Output 1

499122177

Takahashi wins in one spin if the wheel shows 22. Therefore, the probability of winning is 12\frac{1}{2}.

We have 2×4991221771(mod998244353)2\times 499122177 \equiv 1 \pmod{998244353}, so the answer to be printed is 499122177499122177.

Sample Input 2

10 5 6

Sample Output 2

184124175

Sample Input 3

100 1 99

Sample Output 3

0

update @ 2024/3/10 11:35:26