A Math Contest P8 - Permutation Counting
View as PDFCalculate the number of permutations of the first  positive integers which can be sorted by performing exactly 
 swaps of adjacent elements.
Constraints
Input Specification
The only line contains two space-separated integers,  and 
.
Output Specification
Output the number of permutations of the first  positive integers which can be sorted by performing exactly 
 adjacent swaps. Since this value may be large, output it modulo 
.
Sample Input
3 3
Sample Output
3
Explanation for Sample
The permutations of  which can be sorted by performing exactly 
 adjacent swaps are 
, 
 and 
.
Comments