GCD of Prefixes
Sasuke and Itachi are playing a game. Sasuke first creates an array $A$ containing $N$ positive integers $A_1, A_2, \dots, A_N$. He then creates a new array $B$ of length $N$ such that $B_i = \gcd(A_1, A_2, ..., A_i)$ for each $1 \leq i \leq N$. Now, Sasuke gives array $B$ to Itachi and asks him to find any array $A$ (with $1\leq A_i\leq 10^9$) such that the given process applied to $A$ will produ
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