A12167 | New Year and the Sphere Transmission
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
There are $n$ people sitting in a circle, numbered from $1$ to $n$ in the order in which they are seated. That is, for all $i$ from $1$ to $n-1$ , the people with id $i$ and $i+1$ are adjacent. People with id $n$ and $1$ are adjacent as well.
The person with id $1$ initially has a ball. He picks a positive integer $k$ at most $n$ , and passes the ball to his $k$ -th neighbour in the direction of increasing ids, that person passes the ball to his $k$ -th neighbour in the same direction, and so on until the person with the id $1$ gets the ball back. When he gets it back, people do not pass the ball any more.
For instance, if $n = 6$ and $k = 4$ , the ball is passed in order $[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 = 9$ .
Find and report the set of possible fun values for all choices of positive integer $k$ . It can be shown that under the constraints of the problem, the ball always gets back to the $1$ -st player after finitely many steps, and there are no more than $10^5$ possible fun values for given $n$ .
The person with id $1$ initially has a ball. He picks a positive integer $k$ at most $n$ , and passes the ball to his $k$ -th neighbour in the direction of increasing ids, that person passes the ball to his $k$ -th neighbour in the same direction, and so on until the person with the id $1$ gets the ball back. When he gets it back, people do not pass the ball any more.
For instance, if $n = 6$ and $k = 4$ , the ball is passed in order $[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 = 9$ .
Find and report the set of possible fun values for all choices of positive integer $k$ . It can be shown that under the constraints of the problem, the ball always gets back to the $1$ -st player after finitely many steps, and there are no more than $10^5$ possible fun values for given $n$ .
输入格式
The only line consists of a single integer $n$ ( $2 \leq n \leq 10^9$ ) — the number of people playing with the ball.
输出格式
Suppose the set of all fun values is $f_1, f_2, \dots, f_m$ .
Output a single line containing $m$ space separated integers $f_1$ through $f_m$ in increasing order.
Output a single line containing $m$ space separated integers $f_1$ through $f_m$ in increasing order.
输入输出样例
输入 #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 = 4$ yields fun value $9$ , as does $k = 2$ . Picking $k = 6$ results in fun value of $1$ . For $k = 3$ we get fun value $5$ and with $k = 1$ or $k = 5$ we get $21$ .
In the second sample, the values $1$ , $10$ , $28$ , $64$ and $136$ are achieved for instance for $k = 16$ , $8$ , $4$ , $10$ and $11$ , respectively.
In the second sample, the values $1$ , $10$ , $28$ , $64$ and $136$ are achieved for instance for $k = 16$ , $8$ , $4$ , $10$ and $11$ , respectively.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted