Array and Operations
Chef has an array $a_1,\ldots,a_n$ of $n$ elements. Initially, all elements of the array are equal to $1$. There are two types of operations. - $1$ $i$: Take the index $i$ ($1 \le i \le n$), and multiply it by $2$ ($a_i := 2 \cdot a_i$). - $2$ $i$ $j$: Take two indexes $i$ and $j$ ($1 \le i, j \le n, i \ne j$), and subtract $a_j$ from $a_i$, ($a_i := a_i - a_j$). All elements must be
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