10016: ABC323 —— E - Playlist
[Creator : ]
Description
Takahashi has a playlist with $N$ songs. Song $i$ $(1 \leq i \leq N)$ lasts $T_i$ seconds.
Takahashi has started random play of the playlist at time $0$.
Random play repeats the following: choose one song from the $N$ songs with equal probability and play that song to the end. Here, songs are played continuously: once a song ends, the next chosen song starts immediately. The same song can be chosen consecutively.
Find the probability that song $1$ is being played $(X + 0.5)$ seconds after time $0$, modulo $998244353$.
How to print a probability modulo $998244353$
It can be proved that the probability to be found in this problem is always a rational number. Also, the constraints of this problem guarantee that when the probability to be found is expressed as an irreducible fraction $\frac{y}{x}$, $x$ is not divisible by $998244353$.
Then, there is a unique integer $z$ between $0$ and $998244352$, inclusive, such that $xz \equiv y \pmod{998244353}$. Report this $z$.
Takahashi has started random play of the playlist at time $0$.
Random play repeats the following: choose one song from the $N$ songs with equal probability and play that song to the end. Here, songs are played continuously: once a song ends, the next chosen song starts immediately. The same song can be chosen consecutively.
Find the probability that song $1$ is being played $(X + 0.5)$ seconds after time $0$, modulo $998244353$.
How to print a probability modulo $998244353$
It can be proved that the probability to be found in this problem is always a rational number. Also, the constraints of this problem guarantee that when the probability to be found is expressed as an irreducible fraction $\frac{y}{x}$, $x$ is not divisible by $998244353$.
Then, there is a unique integer $z$ between $0$ and $998244352$, inclusive, such that $xz \equiv y \pmod{998244353}$. Report this $z$.
Input
The input is given from Standard Input in the following format:
```
$N$ $X$
$T_1$ $T_2$ $\ldots$ $T_N$
```
```
$N$ $X$
$T_1$ $T_2$ $\ldots$ $T_N$
```
Output
Print the probability, modulo $998244353$, that the first song in the playlist is being played $(X+0.5)$ seconds after time $0$.
Constraints
- $2 \leq N\leq 10^3$
- $0 \leq X\leq 10^4$
- $1 \leq T_i\leq 10^4$
- All input values are integers.
- $0 \leq X\leq 10^4$
- $1 \leq T_i\leq 10^4$
- All input values are integers.
Sample 1 Input
3 6
3 5 6
Sample 1 Output
369720131
Song 1 will be playing 6.5 seconds after time 0 if songs are played in one of the following orders.
We have $369720131×27≡7(\bmod\ {998244353})$, so you should print 369720131.
- Song 1 → Song 1 → Song 1
- Song 2 → Song 1
- Song 3 → Song 1
We have $369720131×27≡7(\bmod\ {998244353})$, so you should print 369720131.
Sample 2 Input
5 0
1 2 1 2 1
Sample 2 Output
598946612
0.5 seconds after time 0, the first song to be played is still playing, so the sought probability is $\frac{1}{5}$.
Note that different songs may have the same length.
Note that different songs may have the same length.
Sample 3 Input
5 10000
1 2 3 4 5
Sample 3 Output
586965467