#P4071. [SDOI2016] 排列计数
[SDOI2016] 排列计数
Description
Count the number of permutations of to such that there are exactly positions with .
Output the answer modulo .
Input Format
There are multiple test cases in a single test file.
The first line contains an integer , representing the number of test cases.
The following lines each describe one test case.
For each test case, a single line contains two integers and , in that order.
Output Format
Output lines. For each test case, output one integer representing the answer.
5
1 0
1 1
5 2
100 50
10000 5000
0
1
20
578028887
60695423
Hint
Constraints
This problem contains 20 test points, evenly divided. The constraints for each test point are shown in the table below.
| Test point ID | Test point ID | ||||
|---|---|---|---|---|---|
For all test points, it is guaranteed that , , .
Translated by ChatGPT 5
京公网安备 11011102002149号