QOJ.ac

QOJ

時間限制: 5 s 記憶體限制: 1024 MB 總分: 25

#5882. 循环数字

统计

你是否曾因为电视上总是播放重复的内容而感到沮丧?我个人对电视没什么感觉,但我有时对数字也有这种感觉。

如果一对不同的正整数 $(n, m)$ 可以通过将 $n$ 末尾的一些数字移动到前端(且不改变这些数字的相对顺序)得到 $m$,则称该数对是“循环”的。例如,$(12345, 34512)$ 是一对循环数对,因为你可以通过将 $12345$ 末尾的 $345$ 移到前端得到 $34512$。注意,为了构成循环数对,$n$ 和 $m$ 必须具有相同的位数。$n$ 和 $m$ 均不能有前导零。

给定两个位数相同且无前导零的整数 $A$ 和 $B$,请问有多少个不同的循环数对 $(n, m)$ 满足 $A \le n < m \le B$?

输入格式

输入的第一行包含测试用例的数量 $T$。接下来是 $T$ 个测试用例。每个测试用例由一行组成,包含整数 $A$ 和 $B$。

输出格式

对于每个测试用例,输出一行 "Case #x: y",其中 $x$ 是测试用例编号(从 1 开始),$y$ 是满足 $A \le n < m \le B$ 的循环数对 $(n, m)$ 的数量。

样例

输入格式 1

4
1 9
10 40
100 500
1111 2222

输出格式 1

Case #1: 0
Case #2: 3
Case #3: 156
Case #4: 287

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.