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

24401번 - Alien Integers 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 1024 MB70272541.667%

문제

Exploratory robots are essential to expanding our understanding of the moon, Mars, and other celestial bodies. When there are two or more robots in the same vicinity, they need to be marked by humanly readable integers for purposes of visual tracking. To reduce the possibility of error in visual recognition of the robots in dark and dusty environments, numbers are chosen so that they have no digits in common. More formally, two non-negative integers are alien to each other if there is no digit which occurs in both of their decimal representations. For example, 11ドル,229円$ and 67ドル,840円$ are alien to each other, while 2ドル,022円$ and 427ドル$ are not. No integer is alien to 1ドル,234円,567円,890円$.

The numbers on robots in the same area should also be close to each other numerically (for instance, to simplify processing of the marks by the software, to make them easy to remember, to distinguish them from other groups of robots marked in similar manner, . . . ).

The Institute for Computerized Planetary Circumambulation needs a program to identify the nearest number that is alien to a given number. Can you help?

입력

The input consists of an integer $N$ (1ドル ≤ N ≤ 10^{15}$) given on a single line.

출력

When there is one non-negative alien integer $Y$ closest to the input number $N,ドル output the value of $Y$. When there are two such integers that are equally close to the input number $N,ドル output both of them in ascending order, on a single line. When there is no integer alien to the input number $N,ドル output Impossible.

제한

예제 입력 1

24

예제 출력 1

19

예제 입력 2

605

예제 출력 2

499 711

예제 입력 3

98765432011

예제 출력 3

Impossible

힌트

출처

ICPC > Regionals > North America > North America Qualification Contest > ICPC North America Qualifier 2021 A번

  • 문제를 만든 사람: Marko Berezovsky
(追記) (追記ここまで)

출처

대학교 대회

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

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