[BOJ 8291] Coprime Numbers

View as PDF

Submit solution

Points: 4
Time limit: 5.0s
Memory limit: 128M

Problem types
Allowed languages
Assembly, Awk, C, C++, Java, Pascal, Perl, Python, Sed, Text

Two positive integers are said to be coprime if 1 is their only common divisor. Given a sequence of positive integers a1, a2, ..., an, find the number of pairs of its terms which are coprime.

입력 형식

The first line of input contains one integer n (1 ≤ n ≤ 1,000,000) denoting the length of the sequence. The second line contains n integers ai (1 ≤ ai ≤ 3,000,000).

출력 형식

Your program should output one integer representing the number of pairs (i, j) such that 1 ≤ i < j ≤ n and ai is coprime with aj.

예제 입력

5
3 6 4 7 3

예제 출력

6

Comments

There are no comments at the moment.