Permutation Making
Time limit1sMemory limit1024 MB
Construct a permutation A of 1..N so that its prefix sums mod N produce at most N/2+1 distinct values.
- Level
Medium7 of 10
- Topics
- Math, Number theory, Greedy, Combinatorics
- Solved
- No attempts yet
Problem
A permutation of length is a sequence of natural numbers between and in which no number appears more than once.
You are given a permutation of length .
Define the -th element of a new sequence as follows. ()
Find any permutation for which the number of distinct values among the elements of is at most .
Input
The first line contains ().
Output
Print through , separated by spaces.
A permutation satisfying the condition always exists.