logo AlgoBeat OnlineJudge
登录 注册

#213560. [GCJ 2009 #1B] The Next Number

内存限制:1024 MiB 时间限制:3000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

You are writing out a list of numbers. Your list contains all numbers with exactly digits in its decimal representation which are equal to , for each between 1 and 9, inclusive. You are writing them out in ascending order.

For example, you might be writing every number with two '1's and one '5'. Your list would begin 115, 151, 511, 1015, 1051.

Given , the last number you wrote, compute what the next number in the list will be.

输入格式

The first line of input contains an integer , the number of test cases in the input. lines follow, one for each test case, each containing a single integer .

输出格式

For each test case, output

Case #:

where is the test case number, starting from 1, and is the next integer in the list.

样例

样例输入 1

3
115
1051
6233

样例输出 1

Case #1: 151
Case #2: 1105
Case #3: 6323

数据范围与提示

Limits

Small dataset(9 Pts)

  • Time limit: 20 2 seconds.

Large dataset(26 Pts)

  • Time limit: 30 3 seconds.