#P7439. 「KrOI2021」Feux Follets 弱化版
「KrOI2021」Feux Follets 弱化版
Problem Description
Let be the number of cycles when treating a permutation of length as a permutation mapping. Given two integers and a degree- polynomial, compute:
where ranges over all permutations of length such that there is no position with .
Input Format
The first line contains two integers and .
The second line contains integers, giving the coefficients of the polynomial from low degree to high degree.
Output Format
Output one integer, the answer modulo .
3 2
0 1
2
6 4
11 43 27 7
53070
6 4
9 72 22 7
60990
Hint
Constraints
For of the testdata, .
Translated by ChatGPT 5