#abc260h. Ex - Colorfulness

Ex - Colorfulness

Score : 600600 points

问题描述

设有编号从 11NNNN 个球,其中第 ii 个球被涂成颜色 aia_i

对于 (1,2,,N)(1, 2, \dots, N) 的一个排列 P=(P1,P2,,PN)P = (P_1, P_2, \dots, P_N),我们定义 C(P)C(P) 如下:

  • 当按顺序将球 P1,P2,,PNP_1, P_2, \dots, P_N 排成一行时,相邻球颜色不同的球对数量。

SNS_N 表示所有 (1,2,,N)(1, 2, \dots, N) 的排列集合。另外,我们定义 F(k)F(k) 如下:

$\displaystyle F(k) = \left(\sum_{P \in S_N}C(P)^k \right) \mod 998244353$。

求出 F(1),F(2),,F(M)F(1), F(2), \dots, F(M) 的值并列出。

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

Problem Statement

There are NN balls numbered 11 through NN. Ball ii is painted in Color aia_i.

For a permutation P=(P1,P2,,PN)P = (P_1, P_2, \dots, P_N) of (1,2,,N)(1, 2, \dots, N), let us define C(P)C(P) as follows:

  • The number of pairs of adjacent balls with different colors when Balls P1,P2,,PNP_1, P_2, \dots, P_N are lined up in a row in this order.

Let SNS_N be the set of all permutations of (1,2,,N)(1, 2, \dots, N). Also, let us define F(k)F(k) by:

$\displaystyle F(k) = \left(\sum_{P \in S_N}C(P)^k \right) \bmod 998244353$.

Enumerate F(1),F(2),,F(M)F(1), F(2), \dots, F(M).

Constraints

  • 2N2.5×1052 \leq N \leq 2.5 \times 10^5
  • 1M2.5×1051 \leq M \leq 2.5 \times 10^5
  • 1aiN1 \leq a_i \leq N
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN MM

a1a_1 a2a_2 \dots aNa_N

Output

Print the answers in the following format:

F(1)F(1) F(2)F(2) \dots F(M)F(M)

Sample Input 1

3 4
1 1 2

Sample Output 1

8 12 20 36

Here is the list of all possible pairs of (P,C(P))(P, C(P)).

  • If P=(1,2,3)P=(1,2,3), then C(P)=1C(P) = 1.
  • If P=(1,3,2)P=(1,3,2), then C(P)=2C(P) = 2.
  • If P=(2,1,3)P=(2,1,3), then C(P)=1C(P) = 1.
  • If P=(2,3,1)P=(2,3,1), then C(P)=2C(P) = 2.
  • If P=(3,1,2)P=(3,1,2), then C(P)=1C(P) = 1.
  • If P=(3,2,1)P=(3,2,1), then C(P)=1C(P) = 1.

We may obtain the answers by assigning these values into F(k)F(k). For instance, F(1)=11+21+11+21+11+11=8F(1) = 1^1 + 2^1 + 1^1 + 2^1 + 1^1 + 1^1 = 8.

Sample Input 2

2 1
1 1

Sample Output 2

0

Sample Input 3

10 5
3 1 4 1 5 9 2 6 5 3

Sample Output 3

30481920 257886720 199419134 838462446 196874334

update @ 2024/3/10 11:02:50