#abc260h. Ex - Colorfulness
Ex - Colorfulness
Score : points
问题描述
设有编号从 到 的 个球,其中第 个球被涂成颜色 。
对于 的一个排列 ,我们定义 如下:
- 当按顺序将球 排成一行时,相邻球颜色不同的球对数量。
令 表示所有 的排列集合。另外,我们定义 如下:
$\displaystyle F(k) = \left(\sum_{P \in S_N}C(P)^k \right) \mod 998244353$。
求出 的值并列出。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
There are balls numbered through . Ball is painted in Color .
For a permutation of , let us define as follows:
- The number of pairs of adjacent balls with different colors when Balls are lined up in a row in this order.
Let be the set of all permutations of . Also, let us define by:
$\displaystyle F(k) = \left(\sum_{P \in S_N}C(P)^k \right) \bmod 998244353$.
Enumerate .
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the answers in the following format:
Sample Input 1
3 4
1 1 2
Sample Output 1
8 12 20 36
Here is the list of all possible pairs of .
- If , then .
- If , then .
- If , then .
- If , then .
- If , then .
- If , then .
We may obtain the answers by assigning these values into . For instance, .
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