Array Expansion
CodeChefOpen on judge ↗
Suppose you have an array $A$ of length $N$ containing non-negative integers. With the parameter $X$, you can modify the array in the following three ways: 1. Choose an index $i$ ($1 \le i \lt N$) such that $A_i \gt 0$ and $A_{i+1} = 0$, and set $A_{i+1} := \gcd(A_i, X)$. 2. Choose an index $i$ ($1 \lt i \le N$) such that $A_i \gt 0$ and $A_{i-1} = 0$, and set $A_{i-1} := \gcd(A_i, X)$. 3. Choos
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