#P7438. 更简单的排列计数

    ID: 8229 远端评测题 800ms 500MiB 尝试: 0 已通过: 0 难度: 9 上传者: 标签>动态规划 DP数学递推O2优化置换组合数学排列组合前缀和二项式定理生成函数线性递推微积分导数快速傅里叶变换 FFT快速数论变换 NTT

更简单的排列计数

Problem Description

Let cycπ\text{cyc}_\pi be the number of cycles in the cycle decomposition when the permutation π\pi of length nn is viewed as a permutation (mapping). Given two integers n,kn, k and a polynomial of degree k1k-1, for each 1mn1 \leq m \leq n compute:

πF(cycπ)\sum\limits_{\pi} F(\text{cyc}_{\pi})

where π\pi ranges over all permutations of length mm such that there is no position ii with πi=i\pi_i = i.

Input Format

The first line contains two integers nn and kk.

The second line contains kk integers, giving the coefficients of the polynomial from low degree to high degree.

Output Format

Output one line with nn integers, representing the answers modulo 998244353998244353.

3 2
0 1
0 1 2
6 4
11 43 27 7
0 88 176 1311 7332 53070

Hint

Sample Explanation 1

Below are all permutations that satisfy the requirement when m=1,2,3m = 1, 2, 3:

$\text{cyc}_{(2,1)} = 1, \text{cyc}_{(2,3,1)} = 1, \text{cyc}_{(3,1,2)} = 1$. So when m=1m = 1 the answer is 00, when m=2m = 2 it is 11, and when m=3m = 3 it is 22.

Constraints

Subtask ID Score nn \leq kk \leq Other Constraints
Subtask 1 11 1010 66
Subtask 2 55 2×1032\times 10^3
Subtask 3 66 2×1052\times 10^5 11
Subtask 4 1616 66 F(x)=xkF(x)=x^k
Subtask 5 33
Subtask 6 5656 6×1056\times 10^5 100100

For 100%100\% of the testdata, 1n6×1051 \leq n \leq 6\times 10^5, 1k1001 \leq k \leq 100, and 0[xk]F(x)9982443520 \leq [x^k]F(x) \leq 998244352.

Translated by ChatGPT 5