#P7435. 简单的排列计数
简单的排列计数
Problem Description
Let denote the number of inversions of a permutation . If the length of is , then
$$\text{inv}_{\pi}=\sum\limits_{i=1}^{n}\sum\limits_{j=i+1}^{n}[\pi_i>\pi_j]$$Given two positive integers , and a permutation , define the weight of a permutation of length as
$$\text{val}_{\pi}=\prod\limits_{i=1}^{n}\prod_{j=i+1}^{n}\pi_i^{[\pi_{i}>\pi_j]}$$For , compute
where is a permutation of length .
Input Format
The first line contains two integers .
Output Format
Output one line with integers, representing the answers modulo .
3 3
1 5 15 18
Hint
Sample Explanation 1
$$\text{inv}_{(1,2,3)}=0,\text{inv}_{(1,3,2)}=1,\text{inv}_{(2,1,3)}=1,\text{inv}_{(2,3,1)}=2,\text{inv}_{(3,1,2)}=2,\text{inv}_{(3,2,1)}=3$$$$\text{val}_{(1,2,3)}=1,\text{val}_{(1,3,2)}=3,\text{val}_{(2,1,3)}=2,\text{val}_{(2,3,1)}=6,\text{val}_{(3,1,2)}=9,\text{val}_{(3,2,1)}=18$$So when the answer is , when it is , when it is , and when it is .
Constraints
| Subtask ID | Points | ||
|---|---|---|---|
| Subtask 1 | |||
| Subtask 2 | |||
| Subtask 3 | |||
| Subtask 4 | |||
| Subtask 5 | |||
| Subtask 6 |
For of the testdata, ,
Translated by ChatGPT 5