#P6059. [加油武汉] 居家隔离
[加油武汉] 居家隔离
Description
After staying at home for a long time, you need to find some entertainment. Then you see the following game:
You are given a set with elements , and all elements are distinct.
The game consists of rounds in total. In each round, the system randomly picks an element from the set, denoted as . You have two choices:
- Take , then will be your final score.
- Discard . In this case, will be permanently removed from the set, and the game proceeds to the next round.
Note that if there is only one element left in the set, that element cannot be discarded.
Since you are lazy, you choose a very “slacker” strategy:
For the first rounds, discard all numbers you get, and record the maximum among them, denoted as .
After round , use the following strategy:
If the obtained , take immediately. Otherwise, keep discarding until you find an that satisfies the condition, or until only one element remains.
Now you want to know, for each from to , what your expected score is.
All numbers should be taken modulo .
Input Format
The first line contains an integer , the number of elements in the set.
The second line contains integers, describing each element in the set.
Output Format
Output one line with numbers in total. The -th number represents the expected score when .
Let the answer in lowest terms be , where and are coprime. Output the integer such that and . It can be proven that such an integer is unique.
5
1 2 3 4 5
698771051 399297745 349385527 3
Hint
Sample Explanation
The four numbers that should be output are , but under modulo arithmetic, dividing by a number is equivalent to multiplying by its modular inverse, so the output is these values modulo . For example, $\frac{39}{10}\equiv 39\cdot 10^{-1}\equiv 39\cdot 299473306\equiv 698771051\pmod{998244353}$.
Hint: If you do not know how to take a fraction modulo a number, click here: https://www.luogu.com.cn/problem/P2613.
- For of the testdata, .
- For of the testdata, the set is all positive integers in .
- For of the testdata, , and all numbers in the set are at most .
Translated by ChatGPT 5
京公网安备 11011102002149号