#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 nn elements {a1,a2,a3....an}\{a_1,a_2,a_3....a_n\}, and all elements are distinct.

The game consists of nn rounds in total. In each round, the system randomly picks an element from the set, denoted as xx. You have two choices:

  1. Take xx, then xx will be your final score.
  2. Discard xx. In this case, xx 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 kk rounds, discard all numbers you get, and record the maximum among them, denoted as yy.

After round kk, use the following strategy:

If the obtained x>yx > y, take xx immediately. Otherwise, keep discarding until you find an xx that satisfies the condition, or until only one element remains.

Now you want to know, for each kk from 11 to n1n-1, what your expected score is.

All numbers should be taken modulo 998244353998244353.

Input Format

The first line contains an integer nn, the number of elements in the set.

The second line contains nn integers, describing each element in the set.

Output Format

Output one line with n1n-1 numbers in total. The ii-th number represents the expected score when k=ik=i.

Let the answer in lowest terms be ab\frac{a}{b}, where aa and bb are coprime. Output the integer xx such that bxa(mod998244353)bx\equiv a \pmod{998244353} and 0x<9982443530\leq x < 998244353. It can be proven that such an integer xx is unique.

5
1 2 3 4 5
698771051 399297745 349385527 3

Hint

Sample Explanation

The four numbers that should be output are 3910,195,6920,3\frac{39}{10}, \frac{19}{5} ,\frac{69}{20}, 3, but under modulo arithmetic, dividing by a number is equivalent to multiplying by its modular inverse, so the output is these values modulo 998244353998244353. 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 40%40\% of the testdata, 2n102 \leq n \leq 10.
  • For 60%60\% of the testdata, the set is all positive integers in [1,n][1,n].
  • For 100%100\% of the testdata, 2n10002 \leq n \leq 1000, and all numbers in the set are at most 1000010000.

Translated by ChatGPT 5