A Math Contest P13 - Ways

View as PDF

Submit solution

Points: 17
Time limit: 1.0s
Memory limit: 256M

Author:
Problem type

There are N objects, and you need to choose M of them. Determine the number of ways to choose objects, where the order does not matter. Since this answer may be quite large, output this value modulo K.

Constraints

1 \leq M \leq N \leq 10^{18}

1 \leq K \leq 10^6

Input Specification

The only line contains three space-separated integers, N, M and K.

Output Specification

Output the number of unordered ways to choose M of the N objects, modulo K.

Sample Input

5 3 111

Sample Output

10

Comments

There are no comments at the moment.