K-transform
시간 제한2초메모리 제한256 MB
k진법 함수 f를 정확히 m번 적용해 1이 되는 양의 정수 n의 개수를 소수 mod로 나눈 나머지를 구한다.
문제
Let us fix an integer and define a function : :
If we take some integer and will apply function some (possibly ) times then we will end up with . For example, if then .
Your task is to calculate the amount of such that we will end up with after exactly iterations. The answer may be very large, so you have to output it modulo .
입력
The first line contains three integers separated by spaces: , , (, , ). It is guaranteed that is prime.
출력
Print one integer: the answer to the problem modulo .
힌트
is the set of positive integers.