Small GCD Sort
There are $N$ players, numbered from $1$ to $N$. Player $i$'s score is defined to be $\gcd(i, N)$. Here, $\gcd(i, N)$ refers to the largest positive integer that divides both $i$ and $N$. Your task is to find an ordering of the players, from left to right, that satisfies the following conditions: - Between two players with different scores, the one with a higher score must appear somewhere to
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