Min Modular Subarray
Given an integer $M$ and for an array $A$ of length $N$, define - $S(i, j) = A_i + A_{i + 1} + \ldots + A_j$ for $1 \le i \le j \le N$. - $T(i, j) = \min(S(i, j) \bmod M, (M - S(i, j)) \bmod M)$ - $f(A, M) = \displaystyle\min_{1 \le i \le j \le N}(T(i, j))$ For each $N = 1, 2, \ldots, M$, find the sum of $f(A, M)$ over all $M^N$ arrays satisfying - $0 \le A_i < M$ - $|A| = N$ Since the an
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