← All problemsSign in

Coprime Triples

CodeChefRating 2484Open on judge ↗

You are given a sequence a1, a2, ..., aN. Count the number of triples (i, j, k) such that 1 ≤ i j k ≤ N and GCD(ai, aj, ak) = 1. Here GCD stands for the Greatest Common Divisor. Input The first line of input contains a single integer N - the length of the sequence. The second line contains N space-separated integers - a1, a2, ..., aN respectively. Output Output the required number of tripl

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