← All problemsSign in

GCD Partition

CodeChefRating 3082Open on judge ↗

A **valid split** is defined as splitting the array into contiguous, non-empty subsegments such that each element belongs to exactly one subsegment, and the GCD (Greatest Common Divisor) of the $i$-th segment is equal to $i$, where the subsegment numbering starts from $1$ and goes up to $k$, with $k$ being the total number of subsegments. Let $F(C)$ be a function on an array $C$ = count of differ

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