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

7109번 - The Value of an Expression 다국어

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

문제

The operation # is defined for any two positive integers.

If x and y are positive integers, then

(x#y) = sum_of_digits_in_x_decimal_notation × greatest_digit_in_y_decimal_notation + least_digit_in_y_decimal_notation

For example, (9#30) = 9×3+0 = 27, but (30#9) = 3×9+9 = 36.

Let us say that this problem's expression is such an expression which is either the single variable a (whose value is positive integer), or it can be written in the form (this problem's expression # this problem's expression).

For example, the following expressions are this problem's expressions:

  • a
  • (a#a)
  • ((a#a)#a)
  • (a#((a#a)#((a#a)#a)))

You are to write a program, which for the given value of a determines what is the least possible number of operations # with which this problem's expression with given value K (K - positive integer) can be written.

입력

From the keyboard two positive integer values are input - the value of integer variable a (1 ≤ a ≤ 999999999) and the value of the expression K (1 ≤ K ≤ 999999999).

출력

On the screen the least necessary number of operations # must be written. If for the given value of a it is impossible to obtain K as a value of this problem's expression , then the word 'NEVAR' must be written.

제한

예제 입력 1

718 81

예제 출력 1

3

예제 입력 2

999 333

예제 출력 2

NEVAR

힌트

출처

Olympiad > Latvian olympiad in informatics > 10th Latvian olympiad in informatics > Stage III (Country) 1번

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

출처

대학교 대회

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

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