atcoder#ARC133F. [ARC133F] Random Transition
[ARC133F] Random Transition
Score : points
Problem Statement
Given is an integer .
Snuke is going to do the procedure below.
- Let be a variable and initialize it with a random integer between and (inclusive). For each , is chosen with probability .
- Repeat the following operation times.- With probability , decrease the value of by ; with probability , increase it by . (Here, note that will still be between and after the operation.)
- With probability , decrease the value of by ; with probability , increase it by . (Here, note that will still be between and after the operation.)
For each , find the probability, modulo , that after the procedure.
Definition of probability modulo $998244353$
It can be proved that the sought probabilities are always rational numbers. Additionally, under the Constraints of this problem, when representing each of them as an irreducible fraction , it can be proved that . Thus, there uniquely exists an integer such that $R \times Q \equiv P \pmod{998244353}, 0 \leq R < 998244353$. Answer with this .
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
For each , print the probability, modulo , that after the procedure.
2 1
0 1000000000 0
499122177 0 499122177
First, is always initialized with . In the subsequent operation, the value of is decreased by with probability and increased by with probability . Eventually, we will have with probabilities , respectively.
4 2
200000000 200000000 200000000 200000000 200000000
723727156 598946612 349385524 598946612 723727156
10 100
21265166 263511538 35931763 26849698 108140810 134702248 36774526 147099145 58335759 4118743 163270604
505314898 24510700 872096939 107940764 808162829 831195162 314651262 535843032 665830283 627881537 696038713