#P7474. 「C.E.L.U-02」学术精神

    ID: 8149 远端评测题 1000ms 128MiB 尝试: 0 已通过: 0 难度: 6 上传者: 标签>动态规划 DP数学Special Judge动态规划优化连通块期望

「C.E.L.U-02」学术精神

Problem Description

A one-sentence statement is provided for reading.

There are nn children in a place. Each child has a unique idea, and the ID of the idea owned by the ii-th child is ii. The teacher asks each child to randomly draw one card from a set of cards numbered 1n1 \sim n. 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 A\mathbf A and contest B\mathbf B are connected, and contest B\mathbf B and contest C\mathbf C are connected, then contest A\mathbf A and contest C\mathbf C are also connected. To avoid misunderstanding, here is an example:

Suppose there are only four contests. Contest 1 contains ideas 11, 22; contest 2 contains ideas 22, 55; contest 3 contains ideas 33, 55, 88; contest 4 contains ideas 44, 77. 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 E0E_0 of the total number of times everyone draws a card, and the expectation E1E_1 of the number ss of contest sets.


One-sentence statement:

For each node ii, randomly connect an undirected edge to a node in [1,n][1,n]. 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 nn.

Output Format

Output E0E_0 on the first line, and E1E_1 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 998244353998244353. 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 00 points for this test.

If only the first question is correct, you get 33 points.

If only the second question is correct, you get 77 points.

If both questions are correct, you get 1010 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 11 is 12\dfrac{1}{2}, the probability that the number of draws is 22 is 14\dfrac{1}{4}, and the probability that the number of draws is ii is 12i\dfrac{1}{2^i}. The expected number of draws is 22, so the total expected number of draws is 44.

  • Child 11 will definitely exchange ideas with child 22, so the contests they create must belong to the same contest set. E1=1E_1=1.

Sample Explanation 2

  • The answer to the first question before taking modulo is 496\dfrac{49}{6}.

  • The answer to the second question before taking modulo is 22451944\dfrac{2245}{1944}.


Constraints

Test Point ID nn Test Point ID nn
11 3\leq 3 55 1000\leq 1000
22 5\leq 5 66 2000\leq 2000
33 9\leq 9 787\sim8 5000\leq 5000
44 12\leq 12 9109\sim 10 104\leq10^4

For 100%100\% of the testdata, 2n1042\leq n\leq10^4.


Translated by ChatGPT 5