Codeforces Round 1133 (Div. 1, Div. 2) is coming soon! Register here. ×

Calculate nCr mod p^x

Revision en3, by mr_warlock, 2025-04-04 00:57:14

I am stuck on this following problem:

Statement:

Given n, r, x and P where P is a PRIME number.

Print the value nCr % P^x

Constraints:

1 <= r <= n <= 1e12
2 <= x <= 32
2 <= P^x <= 1e6

Thanks for reading the problem. It will be really helpful if you can give me a solution.

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en4 English mr_warlock 2025-04-04 00:58:53 2 Tiny change: '2 <= x <= 32 \n2 <= ' -> '2 <= x <= 20 \n2 <= '
en3 English mr_warlock 2025-04-04 00:57:14 10 Tiny change: ' n <= 1e12\n\n2 <= x <= 32\n\n2 <= P^x' -> ' n <= 1e12 \n2 <= x <= 32 \n2 <= P^x'
en2 English mr_warlock 2025-04-04 00:55:22 4 Tiny change: ' <= 1e12\n2 <= x <= 32\n2 <= P^x' -> ' <= 1e12\n\n2 <= x <= 32\n\n2 <= P^x'
en1 English mr_warlock 2025-04-04 00:54:07 324 Initial revision (published)