← All problemsSign in

GCD Reduction

CodeChefRating 2648Open on judge ↗

For an array $A$ of length $N$, we obtain its *score* as follows. Perform the following operation $N-2$ times: - If $\gcd(A_1, A_3) \leq \gcd(A_2, A_3)$, delete $A_1$ from $A$. Otherwise, delete $A_2$. After the deletion, the remaining elements are re-indexed to start from $1$. In the end, the array will have exactly two elements remaining. Its score is defined to be the first of these two

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.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start