406307: GYM102348 J Monocarp and T-Shirts

Memory Limit:512 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

J. Monocarp and T-Shirtstime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard output

Monocarp is going to participate in $$$n$$$ different programming contests, and he plans to win a T-shirt in every contest. Of course, he doesn't need $$$n$$$ T-shirts — he wants to give all of them to his friends. Monocarp has a list of $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, ..., $$$a_n$$$ — the sizes of T-shirts that his friends want to receive. All values of $$$a_i$$$ are distinct.

To receive all $$$n$$$ T-shirts for all $$$n$$$ friends, Monocarp chooses different sizes of T-shirts while registering on different competitions — when registering on contest $$$i$$$, he specifies that he would like to receive a T-shirt of size $$$a_i$$$.

Monocarp is absolutely sure that his programming skills are enough to win a T-shirt in each contest. Unfortunately, it is possible that he will receive a T-shirt of wrong size: if he specifies that he wants a T-shirt of size $$$x$$$, then with probability $$$p$$$ he receives a T-shirt having size $$$x - 1$$$, with probability $$$q$$$ he receives a T-shirt having size $$$x + 1$$$, and with probability $$$1 - p - q$$$ he receives a T-shirt having size $$$x$$$.

After receiving all the T-shirts Monocarp starts handing them out: for each $$$a_i$$$, if he has received at least one T-shirt of size $$$a_i$$$, he gives exactly one T-shirt of this size to the friend that asked for a T-shirt of this size. Now Monocarp is interested how many friends (on average) will receive T-shirts. Help him to calculate the expected number of T-shirts he will hand out.

Input

The first line contains three integers $$$n$$$, $$$P$$$ and $$$Q$$$ ($$$1 \le n \le 2 \cdot 10^5$$$, $$$0 \le P \le 10^6$$$, $$$0 \le Q \le 10^6$$$, $$$P + Q \le 10^6$$$) — the number of contests and the numbers denoting the probability to receive a T-shirt of wrong size. $$$p$$$ and $$$q$$$ from the statement can be calculated the following way: $$$p = \frac{P}{10^6}$$$, $$$q = \frac{Q}{10^6}$$$.

The second line contains $$$n$$$ integers $$$a_1$$$, $$$a_2$$$, ..., $$$a_n$$$ ($$$1 \le a_i \le 10^9$$$) — the sizes of T-shirts Monocarp's friends want. All values of $$$a_i$$$ are distinct.

Output

The expected number of T-shirts that Monocarp will hand out can be represented as an irreducible fraction $$$\frac{X}{Y}$$$, where $$$Y$$$ is not divisible by $$$998244353$$$. Print $$$(X \cdot Y^{-1})$$$ $$$mod$$$ $$$998244353$$$, where $$$Y^{-1}$$$ is the inverse of $$$Y$$$ modulo $$$998244353$$$ (a number such that $$$Y \cdot Y^{-1}$$$ is congruent to $$$1$$$ modulo $$$998244353$$$).

ExamplesInput
4 250000 250000
3 1 5 2
Output
530317315
Input
3 125000 750000
3 2 1
Output
175472642
Note

Explanations for the examples:

In the first example $$$p = \frac{1}{4}$$$, $$$q = \frac{1}{4}$$$, the answer is $$$\frac{79}{32}$$$.

In the second example $$$p = \frac{1}{8}$$$, $$$q = \frac{3}{4}$$$, the answer is $$$\frac{467}{256}$$$.

加入题单

算法标签: