King Sam and His Exam

3.5

44 votes
Easy-Medium
Problem

King Sam is known for his intelligence. To test him, Minister Mistry gave him a question. Now, he needs your help to solve the question and prove himself before Minister Mistry. The question goes like this,

F(n,k,m) = (ni=1ij=1jk) % m

Constraints :

1 <= n <= 10^18

1 <= k <= 10^18

1 <= m <= 10^6

Input Format:

Input file consists of a single line which contains 3 integers n, k, m.

Output Format:

Output F(n,k,m).

Sample Input
7 2 5
Sample Output
1
Time Limit: 1
Memory Limit: 256
Source Limit:
Editor Image

?