#P1521. 求逆序对
求逆序对
Description
We call an inversion of if and only if and . For example, has 3 inversions: . Now given and , find the number of permutations of whose number of inversions is exactly . Output that count.
For example, when , , there are 15 valid permutations. They are:
- [1, 2, 5, 4, 3].
- [1, 3, 4, 5, 2].
- [1, 3, 5, 2, 4].
- [1, 4, 2, 5, 3].
- [1, 4, 3, 2, 5].
- [1, 5, 2, 3, 4].
- [2, 1, 4, 5, 3].
- [2, 1, 5, 3, 4].
- [2, 3, 1, 5, 4].
- [2, 3, 4, 1, 5].
- [2, 4, 1, 3, 5].
- [3, 1, 2, 5, 4].
- [3, 1, 4, 2, 5].
- [3, 2, 1, 4, 5].
- [4, 1, 2, 3, 5].
Input Format
The first line contains two integers and .
Output Format
Output the number of permutations of whose number of inversions is . To avoid big integer arithmetic, output the result modulo .
5 3
15
Hint
Constraints
For all testdata, it is guaranteed that , .
Translated by ChatGPT 5
京公网安备 11011102002149号