CF BUDDY
← Problems·

1091C · New Year and the Sphere Transmission

1400 · math, number theory

Problem: 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 n1n-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.

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

Output Format: 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.

Note: 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.

Sample Cases

Case 1

Input

6

Output

1 5 9 21

Case 2

Input

16

Output

1 10 28 64 136

Similar problems

00:00:00
Loading editor…
Welcome! I'm your coding tutor for this problem. Use the chips below to reveal stored hints or get AI feedback on your code. I'll guide you step by step — never giving away the solution.

Sign in to unlock AI tutor feedback