• [E] Palindromic

  • 时间限制: 1000 ms 内存限制: 65535 K
  • 问题描述
  • Vinci is a little boy and is very creative. One day his teacher asked him to write all the Palindromic numbers from 1 to 1000. He became very frustrated because there is nothing creative in the task. Observing his expression, the teacher replied, "All right then, you want hard stuff, you got it." Then he asks Vinci to write a palindromic number which is greater than the given number. A number is called palindromic when its digits are same from both sides. For example: 1223221, 121, 232 are palindromic numbers but 122, 211, 332 are not. As there can be multiple solutions, Vinci has to find the number which is as small as possible.
  • 输入
  • Input starts with an integer T (≤ 30), denoting the number of test cases.
    Each case starts with a line containing a positive integer. This integer can be huge and can contain up to 10^5 digits.
  • 输出
  • For each case, print the case number and the minimum possible palindromic number which is greater than the given number.
  • 样例输入
  • 5
    121
    1
    1332331
    11
    1121
  • 样例输出
  • Case 1: 131
    Case 2: 2
    Case 3: 1333331
    Case 4: 22
    Case 5: 1221
  • 提示
  • Dataset is huge, use faster I/O methods.
  • 来源
  • Hungar
  • 操作

显示春菜