Divisible by i
You are given an integer $N$. Construct a permutation $P$ of length $N$ such that - For all $i$ $(1 \leq i \leq N-1)$, $i$ divides $abs(P_{i+1}-P_i)$. Recall that a permutation of length $N$ is an array where every integer from $1$ to $N$ occurs exactly once. It can be proven that for the given constraints at least one such $P$ always exists. ### Input - The first line of input contains a si
HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17
CodeSearch Tutor
Hints, not spoilers — it won’t hand over the full solution unless you insist.
Sign in to chat with the tutor and save your progress.
Sign in to start