QOJ.ac

QOJ

Limite de temps : 2.0 s Limite de mémoire : 1024 MB Points totaux : 100 Hackable ✓

#7797. 基于零的

Statistiques

Barbara 一直以来都只知道如何用十进制(以 10 为底)表示整数,即使用数字 $0, 1, 2, \dots, 9$。最近她了解到,对于任何整数底数 $b \ge 2$,她也可以用底数 $b$ 来表示整数,使用从 $0$ 到 $b-1$ 的值作为数字。

Barbara 最喜欢的数字是 $0$。幸运的是,它在所有进制下看起来都是一样的。

今天,Barbara 正在研究一个正整数 $n$。现在她想知道:在哪些进制下,$n$ 的表示中包含的 $0$ 的个数最多?请帮她找出所有这样的进制。

输入格式

每个测试包含多个测试用例。第一行包含测试用例的数量 $t$ ($1 \le t \le 1000$)。 接下来是各测试用例的描述。 每个测试用例仅包含一行,为一个整数 $n$ ($2 \le n \le 10^{18}$)。

输出格式

对于每个测试用例,第一行输出两个整数 $k$ 和 $m$,分别表示在任意整数进制下,$n$ 的表示中包含的 $0$ 的最大个数,以及满足该条件的进制数量。 第二行输出 $m$ 个整数 $b_1, b_2, \dots, b_m$,表示所有这些进制,按升序排列 ($2 \le b_1 < b_2 < \dots < b_m \le n$)。

样例

样例输入 1

3
11
1007
239

样例输出 1

1 3
2 3 11
2 2
3 10
1 4
2 6 15 239

说明

以下是样例测试用例中具有最多 $0$ 的表示:

  • $11 = 1011_2 = 102_3 = 10_{11}$(一个 $0$);
  • $1007 = 1101022_3 = 1007_{10}$(两个 $0$);
  • $239 = 11101111_2 = 1035_6 = 10E_{15} = 10_{239}$(一个 $0$)。

在 $239 = 10E_{15}$ 的表示中,$E$ 代表值为 $14$ 的数字。

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.