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

3189번 - tomo 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 128 MB3021038536.325%

문제

The most advanced feature of Tom’s old calculator is that when he multiplies two numbers and continues to press the button '=', calculator continues to multiply the displayed number with the second of the two entered numbers. For example, if he multiplies 2 and 3, the number 6 will appear on the display. Further pressing the button '=' will result in numbers 18, 54, 162, etc. being displayed.

Tom is playing one interesting game – he wants to know how many times does he need to press the '=' button in order for some given number to appear as suffix of the number displayed on the calculator.

More precisely, Tom enters a number A, presses the button '*', enters the number B and presses the button '='. After that, product of the numbers A and B appears on the display. If the number C is not a suffix of the number displayed, Tom continues to press the button '=', until a number whose suffix is C is displayed.

We say that number X is suffix of number Y if the decimal representation of number Y ends with the decimal representation of number X (for example, 46 is suffix of 1246, but 70 is not suffix of 4701). We assume that the calculator can handle numbers with arbitrary many digits and that it can display all those digits.

Write a program that will, given numbers A, B and C, calculate the total number of times the button '=' will be pressed.

입력

First and only line of input contains integers A, B and C, 0 ≤ A, C ≤ 100,000, 0 ≤ B ≤ 1000. There will be no leading zeros in the representation of number C.

출력

First and only line of output should contain the number of times the button '=' will be pressed, or the word 'NIKAD' if there is no solution.

제한

예제 입력 1

2 3 4

예제 출력 1

3

예제 입력 2

1 2 3

예제 출력 2

NIKAD

예제 입력 3

5 3 215

예제 출력 3

5

힌트

출처

Olympiad > Croatian Highschool Competitions in Informatics > 2005 > National Competition #1 - Juniors 1번

  • 데이터를 추가한 사람: ho94949
(追記) (追記ここまで)

출처

대학교 대회

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

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