Let
be a prime number. You are given three integers .
First, define negative exponents as follows. When , is the unique integer satisfying
For an integer , define as follows.
If an integer satisfies
then is called a possible value of .
Given , output the sum of all possible integers .
Here, is considered as an integer satisfying
Input
The input is given in the following format.
Output
Output the sum of all integers satisfying
Constraints
- .
- .
- .
Subtasks
Samples
예제 1
입력
2 3 1
출력
8
Since , we have . Therefore, the answer is .
예제 2
입력
2 1 -1
출력
499122177
The value satisfying is the modular inverse of , which is .
예제 3
입력
2 1 3
출력
275347185
We have .
해설
관리자가 작성한 해설을 별도 페이지에서 볼 수 있어요.