atcoder#ABC289H. [ABC289Ex] Trio
[ABC289Ex] Trio
Score : points
Problem Statement
On a number line are person , person , and person . At time , person is at point , person is at point , and person is at point . Here, , , and are all integers, and .
At time , the three people start random walks. Specifically, a person that is at point at time ( is a non-negative integer) moves to point or point at time with equal probability. (All choices of moves are random and independent.)
Find the probability, modulo , that it is at time that the three people are at the same point for the first time.
What is rational number modulo $998244353$?
We can prove that the sought probability is always a rational number.
Moreover, under the Constraints of this problem, when the value is represented as \frac{P}{Q} by two coprime integers P and Q, we can prove that there is a unique integer R such that R \times Q \equiv P\pmod{998244353} and 0 \leq R \lt 998244353. Find such R.
Constraints
- , and are integers.
Input
The input is given from Standard Input in the following format:
Output
Find the probability, modulo , that it is at time that the three people are at the same point for the first time, and print the answer.
1 1 3 1
873463809
The three people are at the same point for the first time at time with the probability . Since , should be printed.
0 0 0 0
1
The three people may already be at the same point at time .
0 2 8 9
744570476
47717 21993 74147 76720
844927176