#P7438. 更简单的排列计数
更简单的排列计数
Problem Description
Let be the number of cycles in the cycle decomposition when the permutation of length is viewed as a permutation (mapping). Given two integers and a polynomial of degree , for each 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 line with integers, representing the answers modulo .
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 :
$\text{cyc}_{(2,1)} = 1, \text{cyc}_{(2,3,1)} = 1, \text{cyc}_{(3,1,2)} = 1$. So when the answer is , when it is , and when it is .
Constraints
| Subtask ID | Score | Other Constraints | ||
|---|---|---|---|---|
| Subtask 1 | ||||
| Subtask 2 | ||||
| Subtask 3 | ||||
| Subtask 4 | ||||
| Subtask 5 | ||||
| Subtask 6 |
For of the testdata, , , and .
Translated by ChatGPT 5