#P7490. 「Stoi2031」蒲公英的约定(vol.1)
「Stoi2031」蒲公英的约定(vol.1)
Description
Qinghe is playing a game. They have clumps of dandelions, where the -th clump has flowers. These dandelions have a magical property: given a constant , from dandelions they split off as one group, and the remaining continue splitting, until the split-off group has no dandelions, i.e. . They call this phenomenon "renxing" (stubbornness).
Now each clump of dandelions shows this "renxing" phenomenon. The game rules are as follows: starting from Qing, the two players take turns to travel. One travel means choosing one clump of dandelions and blowing away some flowers in the first group of this clump. You must blow away at least one, and at most the size of the first group, i.e. you cannot blow away any dandelions outside the first group. When the first group becomes empty, the next group becomes the first group. If a clump has only one group of dandelions left, then this clump can no longer be chosen. When no clump can be chosen, the game ends, and the player whose turn it is loses.
They want to know: if, on Qing’s first travel, she first chooses uniformly at random one clump of dandelions that can be operated on, and then uniformly at random chooses the number of flowers to blow away, and after that both players play optimally, what is the value of Qing’s win probability ?
The difference from vol.2 is that after part of the dandelions are blown away, they will not regroup.
Input Format
The first line contains two positive integers , where denotes the Subtask number.
The second line contains positive integers; the -th one is .
If , the third line contains two positive integers meaning .
Output Format
Output one integer on one line, which is Qing’s win probability .
4 3
1 1 1
1 6
0
6 3
1 7 3
1 3
5047704042563
Hint
Brief statement:
There are clumps of dandelions. The -th clump has flowers. Given a real number , each clump is split into several groups. The -th group has flowers, and satisfies $t_j=\left\lfloor \sigma\left(s_i - \sum\limits_{k=1}^{j-1}t_k\right) \right\rfloor$. When , no more groups are formed. Two players alternate moves. Each move, a player may choose one clump of dandelions, and choose an integer , and blow away flowers from this clump, changing into , where is the smallest positive integer such that in this clump before the move. You must blow away at least one. If you cannot operate, you lose. Find the value of the first player’s win probability , under the process that the first player’s first move is: uniformly choose any operable clump of dandelions, then uniformly choose the number of flowers to blow away, and after that both players play optimally.
Sample explanation:
For sample , Qing cannot make any move, so the win probability is .
For sample , the initial position is . Qing can choose the -nd clump, and among two possible moves, choose to blow away flowers, resulting in . If she chooses the -rd clump, there is no winning strategy. Also, the -st clump cannot be chosen. Therefore the total win probability is .
Constraints:
This problem uses bundled testdata. The score and limits for each Subtask are as follows.
| Subtask No. | Constraint on | Score | ||
|---|---|---|---|---|
| None | ||||
| None | ||||
For of the data, $1 \le n \le 3 \times 10^5,1 \le s_i \le 10^{10},1 \le p<q \le 10^9$.
The input size is large. You may use the fast input template from the contest statement to speed up reading.
Translated by ChatGPT 5
京公网安备 11011102002149号