Replace with Coefficients
You are given an array $A$ of length $N$ with $0 \le A_i < K$. Consider performing the following operation any number of times on it (possibly zero): - Choose $i, x, y$ such that $1 \le i < N, 0 \le x, y < K$. - Insert $z = ((x \cdot A_i + y \cdot A_{i + 1}) \mod K)$ just before the $i$-th element, and then delete $A_i$ and $A_{i + 1}$. - Formally, the array is changed to $A[1, i - 1] + [z] + 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