atcoder#ABC295E. [ABC295E] Kth Number
[ABC295E] Kth Number
Score : points
Problem Statement
We have a sequence of length consisting of integers between and , inclusive: .
Snuke will perform the following operations 1 and 2 in order.
- For each such that , independently choose a uniform random integer between and , inclusive, and replace with that integer.
- Sort in ascending order.
Print the expected value of after the two operations, modulo .
How to print a number modulo $998244353$?
It can be proved that the sought expected value is always rational. Additionally, under the Constraints of this problem, when that value is represented as \frac{P}{Q} using two coprime integers P and Q, it can be proved that there is a unique integer R such that R \times Q \equiv P\pmod{998244353} and 0 \leq R \lt 998244353. Print this R.Constraints
- All values in the input are integers.
Input
The input is given from Standard Input in the following format:
Output
Print the expected value of after the two operations, modulo .
3 5 2
2 0 4
3
In the operation 1, Snuke will replace with an integer between and . Let be this integer.
- If or , we will have after the two operations.
- If , we will have after the two operations.
- If or , we will have after the two operations.
Thus, the expected value of is .
2 3 1
0 0
221832080
The expected value is .
10 20 7
6 5 0 2 0 0 0 15 0 0
617586310