Square Count
You’re given an array $A$ of size $N$. Count the number of quadruples $(L_1,R_1,L_2,R_2)$ satisfying: - $1 \le L_1 \le R_1 \lt L_2 \le R_2 \le N$; - $\gcd(A_{L_1},\ldots ,A_{R_1}) \times \gcd(A_{L_2},\ldots,A_{R_2})$ is a [perfect square](https://en.wikipedia.org/wiki/Square_number). Note that $\gcd$ denoted the [greatest common divisor](https://en.wikipedia.org/wiki/Greatest_common_divisor).
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