#P4720. Combination Modulo

    ID: 17964 Type: Default 1000ms 256MiB

Combination Modulo

Combination Modulo

Given three integers n, m, and a prime number p, compute the value of the combination $$C(n, m) = \frac{n!}{m!(n-m)!}$$ modulo p.

If m is not in the range [0, n], the answer is 0.

inputFormat

The input consists of a single line containing three space-separated integers: n, m, and p (where p is a prime number).

outputFormat

Output a single integer representing \(C(n, m) \bmod p\).

sample

5 2 13
10