QOJ.ac

QOJ

実行時間制限: 30 s メモリ制限: 1024 MB 満点: 35

#12456. 咆哮的年份

統計

2021 年发生了一些一个多世纪以来从未发生过的事情。2021 年,就像之前的 1920 年一样,是一个“咆哮年”(roaring year)。如果一个正整数 $y$ 的十进制表示(无前导零)可以由两个或多个不同的连续正整数按递增顺序拼接而成,那么该年份 $y$ 就是一个咆哮年。在这种情况下,2021 是一个咆哮年,因为它是 20 和 21 的拼接。

三个来自咆哮年的日历,标记显示了它们的年份是如何“咆哮”的。

咆哮年的其他例子包括 12、789、910、1234、9899100。2020 年不是咆哮年,因为唯一能拼接成 2020 的两个或多个正整数列表是 $[20, 20]$,它不是由连续整数组成的。同样,对于 2019 年,只有三个列表:$[20, 1, 9]$、$[201, 9]$ 和 $[20, 19]$。前两个不是由连续整数组成的,而第三个中的整数不是按递增顺序排列的。因此,2019 年也不是咆哮年。作为最后一个例子,778 不是咆哮年,因为 $[7, 78]$ 和 $[77, 8]$ 不是由连续整数组成的,而 $[7, 7, 8]$ 不是由不同的整数组成的。

给定当前年份(它可能是也可能不是咆哮年),找出下一个咆哮年是什么。

输入格式

输入的第一行包含测试用例的数量 $T$。接下来有 $T$ 行。每一行代表一个测试用例,包含一个整数 $Y$,即当前年份。

输出格式

对于每个测试用例,输出一行 Case #x: z,其中 $x$ 是测试用例编号(从 1 开始),$z$ 是严格大于 $Y$ 的第一个咆哮年。

数据范围

$1 \le T \le 100$。

测试集 1(可见判定)

$1 \le Y \le 10^6$。

测试集 2(隐藏判定)

$1 \le Y \le 10^{18}$。

样例

样例输入 1

4
2020
2021
68000
101

样例输出 1

Case #1: 2021
Case #2: 2122
Case #3: 78910
Case #4: 123

说明

注意在最后一个样例中,102 不是咆哮年,因为 $[10, 2]$ 不是连续整数列表,且你不能在写 2 时加上前导零来使用 $[1, 02]$。

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.