← All problemsSign in

Maximal GCD

CodeChefRating 3951Open on judge ↗

Chef has found an integer array $A$ of length $N$. He defines the *beauty* of an array as the maximal value of $\gcd(A_l, A_{l+1}, \ldots, A_r) \cdot (r - l + 1)$ over all the subsegments $[l, r]$ of the array $A$. Chef loves to explore, so aside from the beauty of the initial array, he wants to know the beauty of the array after performing each of $Q$ updates. Each update replaces a subsegment o

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