← All problemsSign in

All Equal

CodeChefRating 2549Open on judge ↗

For an array $A$ of length $N$, the integer $K$ is said to be *$A$-good* if the following condition holds: - $\gcd(A_i, K) = \gcd(A_j, K)$ for every $1 \leq i \lt j \leq N$. Define $f(A)$ to be the number of integers between $1$ and $M$ that are *$A$-good.* --- You are given integers $N$ and $M$. Compute the sum of $f(A)$ across all $M^N$ arrays $A$ of length $N$ whose elements lie between $1$

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