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

24840번 - Challenge Nine 서브태스크다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
서브태스크 참고 (추가 시간 없음) 1024 MB33213810637.589%

문제

Ada gives John a positive integer $N$. She challenges him to construct a new number (without leading zeros), that is a multiple of 9ドル,ドル by inserting exactly one digit (0 …… 9) anywhere in the given number $N$. It is guaranteed that $N$ does not have any leading zeros.

As John prefers smaller numbers, he wants to construct the smallest such number possible. Can you help John?

입력

The first line of the input gives the number of test cases, $T$. $T$ test cases follow.

Each test case has a single line containing a positive integer $N$: the number Ada gives John.

출력

For each test case, output one line containing Case #x: y, where $x$ is the test case number (starting from 1) and $y$ is the new number constructed by John. As mentioned earlier, $y$ cannot have leading zeros.

제한

  • 1ドル≤T≤100$.

Test Set 1 (8점)

시간 제한: 20 초

  • 1ドル≤N≤10^5$.

Test Set 2 (12점)

시간 제한: 40 초

For at most 10 cases:

  • 1ドル≤N≤10^{123456}$.

For the remaining cases:

  • 1ドル≤N≤10^5$.

예제 입력 1

3
5
33
12121

예제 출력 1

Case #1: 45
Case #2: 333
Case #3: 121212

힌트

In Sample Case #1, there are only two numbers that can be constructed satisfying the divisibility constraint: 45ドル$ and 54ドル$. John chooses the smaller number.

In Sample Case #2, 333ドル$ is the only number possible.

In Sample Case #3, there are four possible options - 212121ドル,ドル 122121ドル,ドル 121221ドル$ and 121212ドル$ - out of which the smallest number is 121212ドル$.

출처

Contest > Google > Kick Start > Google Kick Start 2022 > Round A B번

채점 및 기타 정보

  • 예제는 채점하지 않는다.
(追記) (追記ここまで)

출처

대학교 대회

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

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