Logo
(追記) (追記ここまで)

19499번 - K-transform 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 256 MB149281917.431%

문제

Let us fix an integer $k \ge 2$ and define a function $f$: $\mathbb{N} \rightarrow \mathbb{N}$:

$f(n)= \begin{cases} & n / k \text{, if } k \mid n \\ & n - 1 \text{, otherwise} \end{cases}$

If we take some integer $n \ge 1$ and will apply function $f$ some (possibly 0ドル$) times then we will end up with 1ドル$. For example, if $k=3$ then $f(f(f(f(f(16)))))=f(f(f(f(15))))=f(f(f(5)))=f(f(4))=f(3)=1$.

Your task is to calculate the amount of such $n$ that we will end up with 1ドル$ after exactly $m$ iterations. The answer may be very large, so you have to output it modulo $\mathit{mod}$.

입력

The first line contains three integers separated by spaces: $k,ドル $m,ドル $\mathit{mod}$ (2ドル \le k \le 10^{4},ドル 0ドル \le m \le 10^{18},ドル 2ドル \le \mathit{mod} < 300$). It is guaranteed that $\mathit{mod}$ is prime.

출력

Print one integer: the answer to the problem modulo $\mathit{mod}$.

제한

예제 입력 1

2 4 31

예제 출력 1

5

예제 입력 2

3 13 59

예제 출력 2

36

힌트

$\mathbb{N}$ is the set of positive integers.

출처

Camp > Petrozavodsk Programming Camp > Summer 2016 > Day 7: Ural FU Dandelion Contest E번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /