A Math Contest P13 - Ways

View as PDF

Submit solution

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

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.


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

1 \le K \le 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



There are no comments at the moment.