#P3807. 【模板】卢卡斯定理 / Lucas 定理
【模板】卢卡斯定理 / Lucas 定理
Description
Given integers , compute .
The input guarantees that is prime.
Note: denotes the binomial coefficient.
Input Format
This problem contains multiple test cases.
The first line contains an integer , the number of test cases.
For each test case:
One line with three integers .
Output Format
For each test case, output one line with one integer, the required value.
2
1 2 5
2 1 5
3
3
Hint
For of the testdata, , .
Translated by ChatGPT 5
京公网安备 11011102002149号