#P7439. 「KrOI2021」Feux Follets 弱化版

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

「KrOI2021」Feux Follets 弱化版

Problem Description

Let cycπ\text{cyc}_\pi be the number of cycles when treating a permutation π\pi of length nn as a permutation mapping. Given two integers n,kn, k and a degree-(k1)(k-1) polynomial, compute:

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

where π\pi ranges over all permutations of length nn 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 integer, the answer modulo 998244353998244353.

3 2
0 1
2
6 4
11 43 27 7
53070
6 4
9 72 22 7
60990

Hint

Constraints

For 100%100\% of the testdata, 1n,k1051 \le n, k \le 10^5.

Translated by ChatGPT 5