atcoder#AGC056E. [AGC056E] Cheese
[AGC056E] Cheese
Score : points
Problem Statement
There is a circumference of length . On this circumference, a point whose distance from a certain fixed point, measured in the clockwise direction, is has the coordinate .
For each integer (), there is a mouse at coordinate .
Snuke will throw a piece of cheese times. More specifically, he repeats the following times.
- Choose an integer () randomly, where is chosen with probability percent. This choice is made independently each time.
- Then, throw cheese from the coordinate . The cheese travels in the clockwise direction on the circumference. When the cheese meets a mouse, the following happens.- If the mouse has not eaten cheese:- It eats the cheese with probability . The cheese disappears.
- It does nothing with probability .
- If the mouse has already eaten cheese:- It does nothing.
- If the mouse has not eaten cheese:
- It eats the cheese with probability . The cheese disappears.
- It does nothing with probability .
- If the mouse has already eaten cheese:
- It does nothing.
- The cheese keeps traveling on the circumference until eaten by some mouse.
After throws of cheese, there will be exactly one mouse that has never eaten cheese. For each , find the probability that the mouse at coordinate ends up not eating cheese, modulo .
How to represent a probability modulo $998244353$
We can prove that each probability in question is always a rational number. Additionally, under the Constraints of this problem, when that number is represented as an irreducible fraction , we can also prove that . Thus, there is a unique 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
Print the answers for in one line, with spaces in between.
2
0 100
665496236 332748118
is always chosen. When throwing cheese from this point, the following happens.
- With probability , the mouse at coordinate eats it.
- With probability , the mouse at coordinate eats it.
- With probability , the mouse at coordinate eats it.
- With probability , the mouse at coordinate eats it.
In the end, the mice at coordinates and eat this cheese with probabilities and , respectively.
Therefore, they end up not eating cheese with probabilities and , respectively.
2
50 50
499122177 499122177
10
1 2 3 4 5 6 7 8 9 55
333507001 91405664 419217284 757959653 974851434 806873643 112668439 378659755 979030842 137048051