CF1091C.New Year and the Sphere Transmission

普及/提高-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

There are nn people sitting in a circle, numbered from 11 to nn in the order in which they are seated. That is, for all ii from 11 to n−1n-1, the people with id ii and i+1i+1 are adjacent. People with id nn and 11 are adjacent as well.

The person with id 11 initially has a ball. He picks a positive integer kk at most nn, and passes the ball to his kk-th neighbour in the direction of increasing ids, that person passes the ball to his kk-th neighbour in the same direction, and so on until the person with the id 11 gets the ball back. When he gets it back, people do not pass the ball any more.

For instance, if n=6n = 6 and k=4k = 4, the ball is passed in order [1,5,3,1][1, 5, 3, 1].

Consider the set of all people that touched the ball. The fun value of the game is the sum of the ids of people that touched it. In the above example, the fun value would be 1+5+3=91 + 5 + 3 = 9.

Find and report the set of possible fun values for all choices of positive integer kk. It can be shown that under the constraints of the problem, the ball always gets back to the 11-st player after finitely many steps, and there are no more than 10510^5 possible fun values for given nn.

有 nn 个人围成一圈就座,编号为 11 到 nn,编号顺序即为就座顺序。也就是说,对所有从 11 到 n−1n-1 的 ii,编号为 ii 和 i+1i+1 的人彼此相邻;编号为 nn 和 11 的人也相邻。

编号为 11 的人最初持有一个球。他选择一个不超过 nn 的正整数 kk,并将球沿编号递增方向传给他的第 kk 个邻居;接到球的人再以同样方向传给自己的第 kk 个邻居,依此类推,直到编号为 11 的人再次接到球为止。此时球停止传递。

例如,若 n=6n = 6 且 k=4k = 4,则传球序列为 [1,5,3,1][1, 5, 3, 1]。

考虑所有触碰过球的人组成的集合。游戏的“趣味值”定义为这些人的编号之和。在上述例子中,趣味值为 1+5+3=91 + 5 + 3 = 9。

请找出并输出:对所有正整数 kk 的取值,所能得到的所有可能的趣味值构成的集合。可以证明,在本题约束下,球总会在有限步内回到第 11 位玩家手中,且对给定的 nn,可能的趣味值至多有 10510^5 个。

输入格式

The only line consists of a single integer nn (2≤n≤1092 \leq n \leq 10^9) — the number of people playing with the ball.

唯一的一行包含一个整数 nn(2≤n≤1092 \leq n \leq 10^9)—— 表示参与传球游戏的人数。

输出格式

Suppose the set of all fun values is f1,f2,…,fmf_1, f_2, \dots, f_m.

Output a single line containing mm space separated integers f1f_1 through fmf_m in increasing order.

假设所有趣味值的集合为 f1,f2,…,fmf_1, f_2, \dots, f_m。

输出一行,包含按升序排列的 mm 个以空格分隔的整数:f1f_1 到 fmf_m。

输入输出样例

  • 输入#1

    6

    输出#1

    1 5 9 21
  • 输入#2

    16

    输出#2

    1 10 28 64 136

说明/提示

In the first sample, we've already shown that picking k=4k = 4 yields fun value 99, as does k=2k = 2. Picking k=6k = 6 results in fun value of 11. For k=3k = 3 we get fun value 55 and with k=1k = 1 or k=5k = 5 we get 2121.

In the second sample, the values 11, 1010, 2828, 6464 and 136136 are achieved for instance for k=16k = 16, 88, 44, 1010 and 1111, respectively.

在第一个样例中,我们已经说明:选择 k=4k = 4 可得到趣味值 99,选择 k=2k = 2 同样可得到趣味值 99。选择 k=6k = 6 得到的趣味值为 11;选择 k=3k = 3 得到趣味值 55;而选择 k=1k = 1 或 k=5k = 5 则均可得到趣味值 2121。

在第二个样例中,数值 11、1010、2828、6464 和 136136 分别可在 k=16k = 16、88、44、1010 和 1111 时取得。

输入解题思路,AI测评打分。不知道怎么写?

首页