#P7474. 「C.E.L.U-02」学术精神
「C.E.L.U-02」学术精神
Problem Description
A one-sentence statement is provided for reading.
There are children in a place. Each child has a unique idea, and the ID of the idea owned by the -th child is . The teacher asks each child to randomly draw one card from a set of cards numbered . After drawing, the child puts the card back, and then the child will exchange ideas with the child whose number is on the card (an exchange means that both people tell all the ideas they know to each other). Since exchanging ideas with oneself may look silly to them, if the number on the card is the same as their own, the child will draw again (the card has already been put back at this time), and will keep doing so until the number is not their own.
Soon, every child has finished drawing once. Each child will use all the ideas they have collected to create a contest. Because of the exchange of ideas, many contests are connected with each other.
If two contests contain problems with the same idea, we say these two contests are connected. “Connection” is transitive: if contest and contest are connected, and contest and contest are connected, then contest and contest are also connected. To avoid misunderstanding, here is an example:
Suppose there are only four contests. Contest 1 contains ideas , ; contest 2 contains ideas , ; contest 3 contains ideas , , ; contest 4 contains ideas , . Then contest 1 and contest 2 have a direct connection. Although contest 1 and contest 3 have no common idea, they are still connected. Contest 4 has no connection with any other contest.
All contests that are connected will belong to the same contest set, while contests with no connection belong to different contest sets.
In the example above, contests 1, 2, and 3 belong to one contest set, and contest 4 belongs to another.
Find the expectation of the total number of times everyone draws a card, and the expectation of the number of contest sets.
One-sentence statement:
For each node , randomly connect an undirected edge to a node in . If it connects to itself, keep the edge and connect again, repeating until it connects to a different node. Find the expectations of the number of edges and the number of connected components.
Input Format
Input one line containing a positive integer .
Output Format
Output on the first line, and on the second line. It can be proven that both are rational numbers.
To avoid precision errors, you only need to output their results modulo the prime . If you do not know how to take a fraction modulo a prime, you may look up Fermat’s little theorem and multiplicative inverses.
If the output format is wrong or both answers are wrong, you get points for this test.
If only the first question is correct, you get points.
If only the second question is correct, you get points.
If both questions are correct, you get points.
Be sure to output two integers.
2
4
1
7
166374067
539688692
Hint
Sample Explanation
Sample Explanation 1
-
For each child, the probability that the number of draws is is , the probability that the number of draws is is , and the probability that the number of draws is is . The expected number of draws is , so the total expected number of draws is .
-
Child will definitely exchange ideas with child , so the contests they create must belong to the same contest set. .
Sample Explanation 2
-
The answer to the first question before taking modulo is .
-
The answer to the second question before taking modulo is .
Constraints
| Test Point ID | Test Point ID | ||
|---|---|---|---|
For of the testdata, .
Translated by ChatGPT 5