Challenge Nine
면접 대비메모리 제한1024 MB
N에 숫자 하나를 정확히 한 번 끼워 넣어 9의 배수이면서 가장 작은 수를 만들되, 앞자리에 0이 오면 안 된다.
문제
Ada gives John a positive integer . She challenges him to construct a new number (without leading zeros), that is a multiple of , by inserting exactly one digit (0 …… 9) anywhere in the given number . It is guaranteed that 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, . test cases follow.
Each test case has a single line containing a positive integer : the number Ada gives John.
출력
For each test case, output one line containing Case #x: y, where is the test case number (starting from 1) and is the new number constructed by John. As mentioned earlier, cannot have leading zeros.
제한
- .
힌트
In Sample Case #1, there are only two numbers that can be constructed satisfying the divisibility constraint: and . John chooses the smaller number.
In Sample Case #2, is the only number possible.
In Sample Case #3, there are four possible options - , , and - out of which the smallest number is .