#P8688. [蓝桥杯 2019 省 A] 组合数问题
[蓝桥杯 2019 省 A] 组合数问题
Description
Given , find how many pairs satisfy , , and , where is a prime number. Here is a binomial coefficient, which means the number of ways to choose elements from distinct elements to form a set.
Input Format
The first line contains two numbers , where means this test point contains queries, and the meaning of is the same as above.
The next lines each contain two integers , representing one query.
Output Format
Output lines, each line containing one integer representing the corresponding answer. Since the answer may be very large, output the remainder of the answer modulo .
1 2
3 3
1
2 5
4 5
6 7
0
7
3 23
23333333 23333333
233333333 233333333
2333333333 2333333333
851883128
959557926
680723120
Hint
[Sample Explanation]
Among all possible cases, only is a multiple of .
[Constraints]
For all test cases, , , , and is a prime number.
During judging, test cases will be used to test your program. The limits for each test case are as follows:

Lanqiao Cup 2019 Provincial Contest A Group, Problem J.
Translated by ChatGPT 5
京公网安备 11011102002149号