#P3746. [六省联考 2017] 组合数问题
[六省联考 2017] 组合数问题
Description
The binomial coefficient denotes the number of ways to choose items from distinct items. For example, choosing two items from has three possibilities: , , . By definition, a general formula to compute is:
where . (In particular, when , ; when , .)
Xiaocong learned about the divisibility relationship between and during NOIP, and now he wants to go further and study more properties of binomial coefficients. He noticed that whether is a multiple of depends on whether equals . This intriguing fact sparked his interest in the operation (the remainder operation). Now Xiaocong chose four integers , and he wants to know
$$\left( \sum_{i = 0}^\infty C_{nk}^{ik + r} \right) \bmod p,$$that is,
$$\left( C_{nk}^{r} + C_{nk}^{k + r} + C_{nk}^{2k + r} + \cdots + C_{nk}^{(n - 1)k + r} + C_{nk}^{nk + r} + \cdots \right) \bmod p.$$Input Format
The first line contains four integers . All symbols have the meanings given in the problem statement.
Output Format
Output a single integer, the answer.
2 10007 2 0
8
20 10007 20 0
176
Hint
For of the test points, , and is prime.
For another of the test points, .
For another of the test points, .
For another of the test points, .
For another of the test points, , , and is prime.
For another of the test points, , and is prime.
For another of the test points, , , and is prime.
For of the test points, , , .
Translated by ChatGPT 5
京公网安备 11011102002149号