P4720 [Template] Extended Lucas Theorem / exLucas
Background
This is a template problem.
Description
Compute
$${\mathrm{C}}_n^m \bmod{p}$$
where $\mathrm{C}$ is the binomial coefficient.
Input Format
One line with three integers $n, m, p$, with meanings as described in the statement.
Output Format
Output one integer in one line, representing the answer.
Explanation/Hint
For $100\%$ of the testdata, $1 \le m \le n \le {10}^{18}$, $2 \le p \le {10}^6$, and it is **not guaranteed** that $p$ is a prime number.
Translated by ChatGPT 5