#5034. Sugoroku 5
Sugoroku 5
Sugoroku 5
题目描述
There is a board game with squares: square , square , , square .
You have a die (dice) that rolls an integer between and , inclusive, with equal probability for each outcome.
You start on square . You repeat the following operation until you reach square :
Roll the dice. Let be the current square and be the rolled number, then move to square .
Let be the probability of reaching square after exactly operations. Calculate modulo .
What is probability modulo $998244353$?
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 $\frac{P}{Q}$ using two coprime integers $P$ and $Q$, there is exactly one integer $R$ satisfying $R \times Q \equiv P\pmod{998244353}$ and $0 \leq R < 998244353$. Find this $R$.输入格式
The input is given from Standard Input in the following format:
输出格式
Print lines. The -th line should contain modulo .
3 2
0
249561089
748683265
5 5
598946612
479157290
463185380
682000542
771443236
10 6
0
166374059
207967574
610038216
177927813
630578223
902091444
412046453
481340945
404612686
提示
and are integers.For example, you reach square after exactly two operations when the die rolls the following numbers:
A on the first operation, and a on the second operation. A on the first operation, and a on the second operation. A on the first operation, and a on the second operation.
Therefore, $P_2 = \left( \frac{1}{2} \times \frac{1}{2} \right) \times 3 = \frac{3}{4}$. We have , so print for .
标签: AtCoder|abc345G
来源
AtCoder|abc345G