#GL0000315. Truyền bóng đầu năm (New Year and the Sphere Transmission)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Truyền bóng đầu năm (New Year and the Sphere Transmission)
New Year and the Sphere Transmission
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
There are people sitting in a circle, numbered from to in increasing order. Person initially holds a ball. Before the game, choose an integer with .
Each holder passes the ball to the person positions ahead in the direction of increasing ids, wrapping around after person . Passing continues with the same step until the ball returns to person , when the game stops.
The fun value is the sum of the ids of people who have held the ball, counting each person only once.
Find all distinct fun values obtainable by choosing from through , and print them in increasing order.
Input
One line containing integer .
Output
Print all distinct fun values on one line in increasing order, separated by single spaces.
Subtasks
- Subtask 0 (20 points): ; (for each possible step size).
- Subtask 1 (30 points): ; (for each possible step size).
- Subtask 2 (50 points): ; (for each possible step size).
Examples
Example 1
Input
6
Output
1 5 9 21
Explanation
For , only person holds the ball, giving . For , the sequence gives . For , gives . For , everyone receives the ball, giving . Other choices of produce no new sums.
Example 2
Input
16
Output
1 10 28 64 136
Explanation
The number of people touching the ball may be (the divisors of ). Their respective sums are , each printed exactly once in increasing order.