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

13468번 - Multiplying Digits 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
3 초 512 MB176282526.316%

문제

For every positive integer we may obtain a non-negative integer by multiplying its digits. This defines a function f, e.g. f(38) = 24.

This function gets more interesting if we allow for other bases. In base 3, the number 80 is written as 2222, so: f3(80) = 16.

We want you to solve the reverse problem: given a base B and a number N, what is the smallest positive integer X such that fB(X) = N?

입력

The input consists of a single line containing two integers B and N, satisfying 2 < B ≤ 10 000 and 0 < N < 263.

출력

Output the smallest positive integer solution X of the equation fB(X) = N. If no such X exists, output the word “impossible”. The input is carefully chosen such that X < 263 holds (if X exists).

제한

예제 입력 1

10 24

예제 출력 1

38

예제 입력 2

10 11

예제 출력 2

impossible

예제 입력 3

9 216

예제 출력 3

546

예제 입력 4

10000 5810859769934419200

예제 출력 4

5989840988999909996

힌트

출처

ICPC > Regionals > Europe > Northwestern European Regional Contest > Benelux Algorithm Programming Contest > BAPC 2016 H번

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

출처

대학교 대회

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

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