#P4720. 【模板】扩展卢卡斯定理 / exLucas

    ID: 3676 远端评测题 1000ms 256MiB 尝试: 1 已通过: 1 难度: 8 上传者: 标签>中国剩余定理,CRT逆元Lucas 定理

【模板】扩展卢卡斯定理 / exLucas

Description

Compute

Cnmmodp{\mathrm{C}}_n^m \bmod{p}

where C\mathrm{C} is the binomial coefficient.

Input Format

One line with three integers n,m,pn, m, p, with meanings as described in the statement.

Output Format

Output one integer in one line, representing the answer.

5 3 3
1
666 233 123456
61728

Hint

For 100%100\% of the testdata, 1mn10181 \le m \le n \le {10}^{18}, 2p1062 \le p \le {10}^6, and it is not guaranteed that pp is a prime number.

Translated by ChatGPT 5