QOJ.ac

QOJ

時間限制: 2 s - 4 s 記憶體限制: 1024 MB 總分: 35

#5795. 下一个数

统计

你正在写一个数字列表。对于每个 $i$($1 \le i \le 9$),你的列表中包含所有在十进制表示中恰好有 $D_i$ 个数字 $i$ 的数字。你将这些数字按升序排列。

例如,假设你正在写所有包含两个 '1' 和一个 '5' 的数字。你的列表将以 115, 151, 511, 1015, 1051 开头。

给定你写下的最后一个数字 $N$,计算列表中的下一个数字是什么。

输入的第一行包含一个整数 $T$,表示测试用例的数量。接下来有 $T$ 行,每行包含一个整数 $N$。

对于每个测试用例,输出 Case #X: K,其中 $X$ 是从 1 开始的测试用例编号,$K$ 是列表中的下一个整数。

样例

输入格式 1

3
115
1051
6233

输出格式 1

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

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.