QOJ.ac

QOJ

時間限制: 1 s 記憶體限制: 512 MB 總分: 100

#3379. 逆约数和

统计

你的朋友 Odd Even 对数论非常着迷。他喜欢学习对数字进行运算的新方法,并花费无数时间将新学到的知识应用到数字上。例如,去年他学习了欧拉函数 $\phi(n)$,该函数用于计算小于或等于 $n$ 且与 $n$ 互质的正整数个数。此后不久,他便兴致勃勃地手工计算了从 $1$ 到一百万的所有整数的 $\phi(n)$。

最近,他了解到数字 $N$ 的所有约数之和可以通过以下公式计算:

$$\text{sum of divisors}(N) = \prod_{i=1}^{r} \frac{p_i^{(a_i+1)} - 1}{p_i - 1}$$

其中 $p_1^{a_1} p_2^{a_2} \dots p_r^{a_r}$ 是 $N$ 的质因数分解,每个 $p_i$ 互不相同,$a_i$ 是能整除 $N$ 的 $p_i$ 的最大幂次。

Odd Even 想要反向计算该函数;给定一个正整数 $N$,他想找出所有以 $N$ 为约数之和的正整数 $M$,并希望将它们按升序排列整齐地写出来。你认为这太耗时了,因此决定介入并提供计算机辅助。

编写一个程序完成以下任务:给定一个正整数 $N$,输出所有约数之和为 $N$ 的整数 $M$ 的列表(按升序排列),如果不存在这样的数,则告知 Odd Even。

输入格式

输入的第一行包含一个整数 $T$,表示测试用例的数量。接下来的 $T$ 行,每行包含一个整数 $N$。

输出格式

对于每个测试用例,在一行中输出所有符合条件的数,按升序排列,数与数之间用单个空格分隔。如果不存在这样的数,输出 “none!”(不含引号)。

数据范围

  • $0 < N \le 10^9$
  • 输出可能很大。对于 Java,建议使用 StringBuilder 来缓冲输出。

样例

输入 1

4
7
2
126
1524

输出 1

4
none!
68 82
704 1083 1523

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.