QOJ.ac

QOJ

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

#2809. 礼物

الإحصائيات

Laika 决定为她的好朋友,高原魔女 Azusa 准备一份礼物。出于某种我们不知道的原因,这份礼物将是一个由正整数组成的有限集合。如果仅仅是这样,选择礼物将是一件简单的事情,但有几个因素使情况变得复杂。

首先,Laika 的竞争对手 Flatorte 拥有神秘的魔法力量:给定两个整数 $x$ 和 $y$,她可以创造出 $x$ 和 $y$ 的最大公约数(即 $\gcd(x, y)$)。如果 Laika 送出的礼物是 Flatorte 可以立即进行扩充的(即如果她送出的集合 $A$ 满足 $x, y \in A$,但 $\gcd(x, y) \notin A$),那么 Flatorte 就会立即嘲笑她的对手。因此,Laika 的礼物不能被 Flatorte 的力量所改进:如果她送出集合 $A$,那么对于所有 $x, y \in A$,必须满足 $\gcd(x, y) \in A$。

其次,Laika 希望这份礼物具有某种特殊的意义。她与 Azusa 相识已经 $K$ 天了,她希望礼物能体现这一点。因此,她将所有满足上述条件的集合按“Laikan 序”(定义如下)进行了排列,得到了一个无限的有限集合序列 $S_0, S_1, \dots$。她想要选择并送出集合 $S_K$。你能帮她完成吗?

Laikan 序:取两个集合 $A$ 和 $B$。当且仅当 $\max A < \max B$,或者 $\max A = \max B$ 且 $A \setminus \{\max A\}$ 在 Laikan 序中排在 $B \setminus \{\max B\}$ 之前时,称 $A$ 在 Laikan 序中排在 $B$ 之前。为了定义方便,取 $\max \emptyset = -\infty$。注意,对于正整数的有限集合,这总是定义良好的。

输入格式

输入的第一行包含一个整数 $T$,表示测试用例的数量。接下来的 $T$ 行,每行包含一个我们想要查询 $S_K$ 的值 $K$。

输出格式

对于 $T$ 个 $K$ 值中的每一个,输出集合 $S_K$。输出一个集合时,先输出该集合的元素个数,然后按升序输出其元素。

数据范围

  • $1 \le T \le 5$
# 分值 数据范围
1 8 $0 \le K \le 100$
2 21 $0 \le K \le 1\,000\,000$
3 41 $0 \le K \le 500\,000\,000$
4 14 $0 \le K \le 1\,000\,000\,000$
5 16 $0 \le K \le 1\,500\,000\,000$

样例

样例输入 1

5
0
1
2
3
4

样例输出 1

0
1 1
1 2
2 1 2
1 3

样例输入 2

4
5
6
100
1000

样例输出 2

2 1 3
3 1 2 3
5 1 2 3 7 8
7 1 2 3 5 10 11 12

说明

注意 $S_0 = \emptyset, S_1 = \{1\}, S_2 = \{2\}, S_3 = \{1, 2\}, S_4 = \{3\}, S_5 = \{1, 3\}, S_6 = \{1, 2, 3\}, S_{100} = \{1, 2, 3, 7, 8\}, S_{1000} = \{1, 2, 3, 5, 10, 11, 12\}$。这些正是样例中输出的集合(连同它们的大小)。观察到 $S_6 \neq \{2, 3\}$ —— 这是因为 $2, 3 \in \{2, 3\}$,但 $\gcd(2, 3) = 1 \notin \{2, 3\}$。

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
#105EditorialOpen不会搜索,不会打表Sai_tqwq2025-12-12 19:48:10View

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.