Modular Mirrors
You are given two integers $N$ and $M$. You must construct an array $A$ of length $N$ satisfying all of the following conditions: - $0 \le A_i \lt M$ for each $1 \le i \le N$, - There exists at least one index $i$ such that $A_i \gt 0$, and - For every index $i$ with $1 \le i \le N$, $A_i \equiv (A_{i-1} + A_{i+1}) \pmod M$. The boundaries just outside the array are considered to be $0$. That is
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