Non Coprime Neighbours
An array $B$ of length $N$ $(N \ge 2)$ is said to be good if the following conditions hold: - For all $1 \leq i \leq N$, $2 \leq B_i \leq 10^6$ - $gcd(B_{i-1},B_i)\neq1$ for all $i$ $(2 \leq i \leq N)$. You have an array $A$ of length $N$ ($2 \leq A_i \leq 10^5$). You want to make the array $A$ good. To do so, you can change **atmost** $\left \lceil{\frac {2⋅N} 3}\right \rceil $ elements of $A
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