#P6633. [ZJOI2020] 抽卡
[ZJOI2020] 抽卡
Description
Bob likes drawing cards.
Bob recently started playing a card-drawing game called "Zhugong Link". There are different characters in the game, numbered from to . If Bob obtains cards whose numbers are consecutive, he can form the theoretically strongest team.
In the current card pool, there are different cards. Each time he draws, Bob gets one card uniformly at random from the pool. If Bob draws a card he already owns, then nothing happens, which means this draw is wasted. Bob is a cautious person. He wants to know: if he keeps drawing until he has obtained cards with consecutive numbers and then stops, what is the expected number of draws needed.
Input Format
The first line contains two integers .
The second line contains pairwise distinct integers , indicating which characters are in the card pool.
In this statement, is the maximum value among .
Output Format
Output one integer in one line, representing the expected number of draws modulo . That is, if the expected value in lowest terms is , you need to output an integer such that .
3 2
1 2 3
499122180
10 2
1 2 3 4 5 7 8 9 11 12
839792873
Hint
Sample Explanation 1
If the first draw is card , then the expected number of draws is . If the first draw is card or card , then the expected number of draws is . Therefore the answer is $\frac{1}{3}(1 + \frac{3}{2}) + \frac{2}{3}(1 + 3) = 3.5$.
Constraints and Notes
For the first of the testdata, .
For another of the testdata, and .
For another of the testdata, and it is guaranteed that there exists exactly one theoretically strongest team.
For another of the testdata, and it is guaranteed that any two theoretically strongest teams that can be drawn do not overlap.
For the first of the testdata, .
For the first of the testdata, .
For another of the testdata, .
For another of the testdata, .
For of the testdata, $1 \le m \le 200000, 1 \le a_i \le 2m, 2 \le k \le m$. It is guaranteed that there exists at least one theoretically strongest team that can be drawn (i.e., cards with consecutive numbers).
Translated by ChatGPT 5
京公网安备 11011102002149号