아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Won't sum? Must now

시간 제한20초메모리 제한1024 MB

요약
주어진 S를 앞에 0이 없는 회문수 최대 세 개의 합으로 나타내되, 항의 개수를 최소로 줄인다.
난이도

보통10점 중 7점

유형
그리디, 수학, 문자열
정답자
아직 제출이 없습니다

문제

In 2016, it was shown that every positive integer can be written as the sum of three or fewer palindromic terms. For the purposes of this problem, a palindromic term is a string of digits (with no leading zeroes) that represents a positive integer and reads the same forward and backward.

Given a positive integer S, find K palindromic terms that sum to S, such that K is minimized.

입력

The first line of input gives the number of test cases, T. T lines follow, each containing a positive integer S.

출력

For each test case, output one line of the form Case #x: A1 (if only one term is needed), Case #x: A1 A2 (if only two terms are needed), or Case #x: A1 A2 A3 (if three terms are needed), where x is the case number (counting starting from 1), each Ai is a palindromic term (as described above), and the sum of the Ais equals S.

제한

  • 1 ≤ T ≤ 100.

힌트

In Sample Case #1, the input is already a palindrome.

In Sample Case #2, note that 99 99, for example, would also be an acceptable answer. Even though there are multiple instances of 99, they count as separate terms, so this solution uses the same number of terms as 191 7.

Also note that 191 07, 181 8 9, 0110 88, 101 97, 7.0 191.0, and -202 4, for example, would not be acceptable answers.

예제1

  1. 예제 1

    입력
    3
    1
    198
    1234567890
    
    예상 출력
    Case #1: 1
    Case #2: 191 7
    Case #3: 672787276 94449 561686165