← All problemsSign in

Modindrome

CodeChefRating 2278Open on judge ↗

For an array $B$ of length $M$, define a function $f(B)$ as follows: - Pick a positive integer $X$ - Consider the array $C$ of length $M$, where $C_i = B_i\mod X$ - $X$ is called **good** if $C$ is a palindrome - $f(B) = $ the number of **good** positive integers $X$ for the array $B$ - If there are infinitely many such $X$, then $f(B) = -1$ --- Given integers $N$ and $M$. Find the sum of $f(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.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start