#abc215g. G - Colorful Candies 2

G - Colorful Candies 2

Score : 600600 points

问题描述

NN 颗糖果从左至右排列成一行。
每颗糖果具有以下 10910^9 种颜色之一:颜色 11、颜色 22\ldots、颜色 10910^9
对于每个 i=1,2,,Ni = 1, 2, \ldots, N,从左边数第 ii 颗糖果的颜色为 Color cic_i

高桥将从这 NN 颗糖果中随机选择 KK 颗并获取这些糖果。
NN 颗糖果中选择 KK 颗的方式共有 (NK)\binom{N}{K} 种,其中 (NK)\binom{N}{K} 是二项式系数。高桥将以等概率随机选择这 (NK)\binom{N}{K} 种方式中的一种。

由于高桥希望吃到多彩的糖果,他所选糖果的颜色种类越多,他就越开心。
针对每种情况 K=1,2,,NK = 1, 2, \ldots, N,计算高桥所选糖果拥有不同颜色的数量的期望值。
可以证明所求值是一个有理数。按照“注释”部分所述,将这个有理数对 998244353998244353 取模后的结果打印出来。

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

There are NN candies arranged in a row from left to right.
Each candy has one of the following 10910^9 colors: Color 11, Color 22, \ldots, Color 10910^9.
For each i=1,2,,Ni = 1, 2, \ldots, N, the ii-th candy from the left has Color cic_i.

Takahashi will choose KK from the NN candies and get those KK candies.
There are (NK)\binom{N}{K} ways to choose KK from the NN candies, where (NK)\binom{N}{K} is a binomial coefficient. Takahashi will randomly select one of these (NK)\binom{N}{K} ways with equal probability.

Because Takahashi wants to eat colorful candies, the more variety of colors his candies have, the happier he will be.
For each scenario K=1,2,,NK = 1, 2, \ldots, N, find the expected value of the number of different colors Takahashi's candies will have.
We can prove that the sought value is a rational number. Print this rational number modulo 998244353998244353, as described in Notes.

Notes

When you print a rational number, first write it as a fraction yx\frac{y}{x}, where x,yx, y are integers and xx is not divisible by 998244353998244353 (under the constraints of the problem, such representation is always possible). Then, you need to print the only integer zz between 00 and P1P - 1, inclusive, that satisfies xzy(mod998244353)xz \equiv y \pmod{998244353}.

Constraints

  • 1N5×1041 \leq N \leq 5 \times 10^4
  • 1ci1091 \leq c_i \leq 10^9
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN

c1c_1 c2c_2 \ldots cNc_N

Output

Print NN lines. The ii-th line should contain the expected value of the number of different colors Takahashi's candies will have for the scenario K=iK = i, modulo 998244353998244353 as described in Notes.

Sample Input 1

3
1 2 2

Sample Output 1

1
665496237
2

When K=1K = 1, he will get the 11-st candy, 22-nd candy, or 33-rd candy. In any case, his candy will have one color, so the expected value of the number of different colors is 11.

When K=2K = 2, he will get the 11-st and 22-nd candies, 22-nd and 33-rd candies, or 11-st and 33-rd candies.

  • If he gets the 11-st and 22-nd candies, they have two different colors.
  • If he gets the 22-nd and 33-rd candies, they have one color.
  • If he gets the 11-st and 33-rd candies, they have two different colors.

Thus, the expected value of the number of different colors is $\frac{1}{3} \cdot 2 + \frac{1}{3} \cdot 1 + \frac{1}{3} \cdot 2 = \frac{5}{3}$.
Be sure to print it modulo 998244353998244353 as described in Notes.

When K=3K = 3, he will always get the 11-st, 22-nd, and 33-rd candies, which have two different colors, so the expected value of the number of different colors is 22.

Sample Input 2

11
3 1 4 1 5 9 2 6 5 3 5

Sample Output 2

1
725995895
532396991
768345657
786495555
937744700
574746754
48399732
707846002
907494873
7

update @ 2024/3/10 09:33:43