Exp
Time limit5sMemory limit512 MB
Each of n independent monsters grants i experience (0 to k) with probability p_i, totals are capped at x, and the expected capped total must be computed modulo 998244353.
- Level
Hard8 of 10
- Topics
- Probability, Dynamic programming, Math, Prefix sum
- Solved
- No attempts yet
Problem
Find the expected amount of experience a hero gets for beating monsters one by one. Beating each monster gives the hero units of experience () with probability , independently across monsters. If the hero's total experience exceeds , it is capped to exactly . Display the expected amount modulo .
Input
The first line contains three integers , , and (; ; ).
The second line contains real numbers (), given with exactly 4 decimal digits. The sum of is 1.
Output
Display the expected amount of experience the hero gets.
It can be shown that the sought number can be written as an irreducible fraction with . Then there is a unique integer such that and , so display this .
Hint
In the first test case, the hero gets 0 units of experience with probability , 1 unit with probability , and 2 units with probability . Hence the expected amount is 1.
In the second test case, the hero gets 0 units of experience with probability and 1 unit with probability . The expected amount is .