← All problemsSign in

Coprime Subarrays

CodeChefRating 3116Open on judge ↗

The *beauty* of an array $A$ of length $N$ is defined as follows. Let $S$ be a set of pairs of integers satisfying the following conditions: - Each element $(x, y)$ of $S$ should satisfy $1 \leq x \leq y \leq N$. - For each $(x, y) \in S$, $\gcd(A_x, A_{x+1}, A_{x+2}, \ldots, A_y) = 1$ should hold. That is, the GCD of the subarray of $A$ from index $x$ to index $y$ (inclusive) should be $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