아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Wise man

시간 제한1초메모리 제한64 MB

요약
A에서 시작해 매일 A를 (A + A의 가장 큰 자릿수) mod M으로 바꿀 때, N번째 날의 값을 구합니다.
난이도

보통10점 중 6점

유형
수학, 시뮬레이션, 정수론
정답자
아직 제출이 없습니다

문제

Dzoni, a wise man from Serbia, knows the answers for all of the world's questions except one ?! Can you solve this question for him:

On the first day you are given a number AA. Every following day, your number AA will be changed in following way: A=(A+A = (A + biggestDigit(A))biggestDigit(A)) modmod MM. Can you predict the number at the NN-th day? 

The function biggestDigit(A)biggestDigit(A) returns the digit with the biggest value in the number AA. For example: biggestDigit(172)=7biggestDigit(172) = 7.

입력

The single line of input contains three numbers, AA (1≤A<M)(1 \leq A < M), MM (1≤M≤1018)(1\leq M \leq 10^{18}) and NN (1≤N≤1018)(1\leq N \leq 10^{18}).

출력

In the single line, print the value of AA at the NN-th day.

예제2

  1. 예제 1

    입력
    2014 2015 1
    
    예상 출력
    2014
    
  2. 예제 2

    입력
    14 25 115
    
    예상 출력
    16