#P3867. [TJOI2009] 排列计数
[TJOI2009] 排列计数
Description
We know there are permutations of the numbers . Your task is to count how many of these permutations have the property that the difference between any two adjacent numbers does not exceed .
Since the result may be large, output the answer modulo .
Input Format
The input contains a single line with two space-separated integers: .
Output Format
Output the number of valid permutations modulo .
4 2
12
Hint
On 30% of the testdata, .
On 100% of the testdata, , .
Time limit per test point: 10 seconds.
Translated by ChatGPT 5
京公网安备 11011102002149号