atcoder#ABC298E. [ABC298E] Unfair Sugoroku
[ABC298E] Unfair Sugoroku
Score : points
Problem Statement
Takahashi and Aoki will play a game of sugoroku. Takahashi starts at point , and Aoki starts at point . They will take turns throwing dice. Takahashi's die shows with equal probability, and Aoki's shows with equal probability. When a player at point throws his die and it shows , he goes to point . The first player to reach point wins the game. Find the probability that Takahashi wins if he goes first, modulo .
How to find a probability modulo $998244353$
It can be proved that the sought probability is always rational. Additionally, the constraints of this problem guarantee that, if that probability is represented as an irreducible fraction \frac{y}{x}, then x is indivisible by 998244353.Here, there is a unique integer z between 0 and 998244352 such that xz \equiv y \pmod {998244353}. Report this z.
Constraints
- All values in the input are integers.
Input
The input is given from Standard Input in the following format:
Output
Print the answer.
4 2 3 3 2
665496236
If Takahashi's die shows or in his first turn, he goes to point and wins. If Takahashi's die shows in his first turn, he goes to point , and Aoki will always go to point in the next turn and win. Thus, Takahashi wins with the probability .
6 4 2 1 1
1
The dice always show . Here, Takahashi goes to point , Aoki goes to point , and Takahashi goes to point , so Takahashi always wins.
100 1 1 10 10
264077814