102607: [AtCoder]ABC260 Ex - Colorfulness

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Score : $600$ points

Problem Statement

There are $N$ balls numbered $1$ through $N$. Ball $i$ is painted in Color $a_i$.

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

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

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

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

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

Constraints

  • $2 \leq N \leq 2.5 \times 10^5$
  • $1 \leq M \leq 2.5 \times 10^5$
  • $1 \leq a_i \leq N$
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

$N$ $M$
$a_1$ $a_2$ $\dots$ $a_N$

Output

Print the answers in the following format:

$F(1)$ $F(2)$ $\dots$ $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))$.

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

We may obtain the answers by assigning these values into $F(k)$. For instance, $F(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

Input

题意翻译

### 题目描述 给定 $n$ 个小球,第 $i$ 个小球上有一个数 $a_i$。 将小球按照任意顺序排列,定义分值为相邻两个小球数不同的对数。 对于每一个 $k \in [1, m]$,求对于所有排列小球的方案中,分值的 $k$ 次方的和,对 $998244353$ 取模。 ### 输入格式 第一行两个整数 $n, m$。 第二行 $n$ 个整数,表示数组 $a$。 ### 输出格式 一行 $m$ 个整数,表示答案。

Output

分数:600分

问题描述

有编号为1到N的N个球。球i被涂成颜色$a_i$。

对于一个排列$P = (P_1, P_2, \dots, P_N)$,让我们定义$C(P)$如下:

  • 当球$P_1, P_2, \dots, P_N$按这个顺序排列成一行时,相邻的两个球颜色不同的对数。

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

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

枚举$F(1), F(2), \dots, F(M)$。

限制条件

  • $2 \leq N \leq 2.5 \times 10^5$
  • $1 \leq M \leq 2.5 \times 10^5$
  • $1 \leq a_i \leq N$
  • 输入中的所有值都是整数。

输入

输入格式如下:

$N$ $M$
$a_1$ $a_2$ $\dots$ $a_N$

输出

输出格式如下:

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

样例输入1

3 4
1 1 2

样例输出1

8 12 20 36

这里是所有可能的$(P, C(P))$对的列表。

  • 如果$P=(1,2,3)$,则$C(P) = 1$。
  • 如果$P=(1,3,2)$,则$C(P) = 2$。
  • 如果$P=(2,1,3)$,则$C(P) = 1$。
  • 如果$P=(2,3,1)$,则$C(P) = 2$。
  • 如果$P=(3,1,2)$,则$C(P) = 1$。
  • 如果$P=(3,2,1)$,则$C(P) = 1$。

我们可以通过将这些值分配给$F(k)$来获得答案。例如,$F(1) = 1^1 + 2^1 + 1^1 + 2^1 + 1^1 + 1^1 = 8$。


样例输入2

2 1
1 1

样例输出2

0

样例输入3

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

样例输出3

30481920 257886720 199419134 838462446 196874334

加入题单

算法标签: