QOJ.ac

QOJ

Límite de tiempo: 5000 s Límite de memoria: 262144 MB Puntuación total: 100

#418. 约数个数

Estadísticas

在本题中,你需要找到前 $n$ 个恰好有 $k$ 个约数的整数。

整数 $a$ 的约数是指一个整数 $b$,使得商 $\frac{a}{b}$ 也是一个整数。

给定 $n$ 和 $k$,请找出前 $n$ 个恰好有 $k$ 个不同的正整数约数且不超过 $10^{18}$ 的正整数。如果满足条件的整数总数少于 $n$ 个,则找出所有满足条件的整数。

输入格式

输入的第一行包含两个整数 $n$ 和 $k$:需要寻找的整数个数以及要求的约数个数($1 \le n, k \le 110\,000$)。

输出格式

输出 $n$ 个整数,每行一个:按升序排列的前 $n$ 个恰好有 $k$ 个不同的正整数约数且不超过 $10^{18}$ 的正整数。如果只有 $m < n$ 个这样的整数,则在剩下的 $n - m$ 行中每行输出 $-1$。

样例

样例输入 1

5 4

样例输出 1

6
8
10
14
15

样例输入 2

4 29

样例输出 2

268435456
22876792454961
-1
-1

说明

在第一个样例中,你需要输出前五个恰好有四个约数的整数。它们分别是 $6$(约数为 $1, 2, 3, 6$)、$8$(约数为 $1, 2, 4, 8$)、$10$(约数为 $1, 2, 5, 10$)、$14$(约数为 $1, 2, 7, 14$)和 $15$(约数为 $1, 3, 5, 15$)。

在第二个样例中,你需要找到四个最小的、每个都有 $29$ 个约数的整数。它们分别是 $2^{28} = 268\,435\,456$,$3^{28} = 22\,876\,792\,454\,961$,$5^{28} = 37\,252\,902\,984\,619\,140\,625$ 以及 $7^{28} = 459\,986\,536\,544\,739\,960\,976\,801$。后两个整数严格大于 $10^{18}$,因此对于这两个数,输出 $-1$。

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.