QOJ.ac

QOJ

حد الوقت: 3 s حد الذاكرة: 256 MB مجموع النقاط: 100

#4751. 进位制

الإحصائيات

Khodislav 了解到,除了十进制计数系统外,还存在其他系统,例如十六进制系统。他很好奇同一个数字序列在这两个系统中的值之间有什么联系。例如,一个 $K$ 位的数字序列,其十六进制值能否被其十进制值整除?如果从该数字序列的十进制值中减去一个指定的数 $D$,情况会有什么变化吗?

一个数字序列(notation)是由数字组成的序列。序列中可以使用 0 到 9 的数字:它们既属于十进制系统,也属于十六进制系统。数字序列不能以数字 0 开头。一个数字序列的十进制值是指将该序列解释为十进制数所得到的值。一个数字序列的十六进制值是指将该序列解释为十六进制数所得到的值。

输入格式

第一行包含一个整数 $T$ —— 文件中的测试用例数量 ($1 \le T \le 100$)。随后是 $T$ 个测试用例,每行一个。

对于每个测试用例,提供两个整数:$K$ —— 序列的位数,$D$ —— 从十进制值中减去的数 ($2 \le K \le 15$, $0 \le D \le 10^6$)。

输出格式

对于每个测试用例,找出所有符合要求的数字序列。数字序列是指长度为 $K$ 且没有前导零的数字序列,设其十进制值为 $X$,十六进制值为 $Y$,要求满足 $X > D$ 且 $Y$ 能被 $(X - D)$ 整除。

每个测试用例的答案打印在同一行。首先输出找到的数字序列的数量,随后按升序输出所有找到的数字序列,中间用空格分隔。

样例

输入 1

4
5 6
2 0
2 5
2 21

输出 1

3 12510 24990 37950
0
2 16 22
4 22 24 34 96

说明

在第一个测试用例中,数字序列 37950 意味着十进制下的 $X = 37950$,十六进制下的 $Y = 227664$。我们可以看到 $Y = 227664$ 可以被 $X - D = 37944$ 整除。同样地,对于数字序列 24990,$Y = 149904$ 可以被 $X - D = 24984$ 整除;对于数字序列 12510,$Y = 75024$ 可以被 $X - D = 12504$ 整除。

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.