#P10325. 超越(Transcendent)
超越(Transcendent)
Background
The ultimate existence that goes beyond domains and reality—Transcendence.
“Light of Transcendence” Mina is Atlantis’s strongest mage and an unmatched sage. Even so, she never stopped exploring mathematics for a moment.
“The solutions of a monic integer-coefficient polynomial equation are not necessarily integers,” Mina murmured to herself, “but the value of any symmetric polynomial in all its roots must be an integer.”
“This is easy to prove, yet also quite interesting.” Thinking of this, Mina suddenly got an idea for developing new magic.
Problem Description
Mina’s magic needs stages to build. In stage , each attempt succeeds with probability . If it fails, you only need to retry the current stage; if it succeeds, you can enter the next stage.
The final stage requires choosing a magic base . However, this magic is currently unstable. Let be a positive integer generated uniformly at random in the range not exceeding . Then
Finally, if Mina made a total of attempts in the first stages (each attempt counts, regardless of failure or success), her magic will produce energy .
Mina wants to know the expected value of the energy produced by this magic. Of course, she has computed the answer easily. Can you help her verify it?
You only need to output the answer modulo . Clearly, the answer must be a rational number, so you can directly compute its value modulo .
Input Format
The first line contains two positive integers .
The next lines each contain two positive integers , with meanings as described in the statement.
Output Format
Output one line containing one integer, which is the answer.
2 3
1 2
2 3
2 3
103983787
4 5
1 3
1 2
1 4
1 5
1 6
525030616
7 17
1 5
1 5
1 5
1 5
1 3
1 3
1 3
1 2
1 2
1 6
1 6
1 6
1 6
1 6
1 6
1 6
1 6
308796722
Hint
[Explanation for Sample 1]
Here . In the first stages, the success probability of the first stage is , and the success probabilities of the next two stages are both . From this, we can compute that the probability of finishing the first stages in exactly attempts is (I have a clever way to prove it, but unfortunately there is too little space to write it down):
For example, , which is the probability that every stage succeeds in one attempt: .
Another example is . This requires that in some stage there are exactly two attempts, while all other stages succeed in one attempt, i.e.:
In the sample, . Thus, the probability that is , the probability that is , and with probability we have . Therefore the answer is
$$\frac 14\sum_{k\geq 3}p_k (1+(-1)^k)=\frac{11}{48}$$Taking modulo , it equals .
[Explanation for Sample 2]
The answer before taking modulo is .
[Constraints]
This problem uses bundled testdata.
Subtask 1 (7 pts): , .
Subtask 2 (9 pts): , .
Subtask 3 (13 pts): , .
Subtask 4 (13 pts): .
Subtask 5 (15 pts): , .
Subtask 6 (15 pts): There are at most two distinct groups of .
Subtask 7 (28 pts): No special restrictions.
For all data, , , . It is also guaranteed that
$$U_n\left( \frac{b_i}{b_i-a_i}\right)\not \equiv 0 \pmod{998244353}$$where denotes the -th Chebyshev polynomial of the second kind.
[Hint]
What are you looking for? Maybe you can take another look at the background; it might help.
Translated by ChatGPT 5