Coprime ——鞍山C
TimeLimit: 2000/1000 MS (Java/Others) MemoryLimit: 262144/262144 K (Java/Others)
64-bit integer IO format:%I64d
Problem Description
There are n people standing in a line. Each of them has a unique id number.
Now the Ragnarok is coming. We should choose 3 people to defend the evil. As a group, the 3 people should be able to communicate. They are able to communicate if and only if their id numbers are pairwise coprime or pairwise not coprime. In other words, if their id numbers are a, b, c, then they can communicate if and only if [(a, b) = (b, c) = (a, c) = 1] or [(a, b) ≠ 1 and (a, c) ≠ 1 and (b, c) ≠ 1], where (x, y) denotes the greatest common divisor of x and y.
We want to know how many 3-people-groups can be chosen from the n people.
Input
The first line contains an integer T (T ≤ 5), denoting the number of the test cases.
For each test case, the first line contains an integer n(3 ≤ n ≤ 10
5), denoting the number of people. The next line contains n distinct integers a
1, a
2, . . . , a
n(1 ≤ a
i ≤ 10
5) separated by a single space, where a
i stands for the id number of the i-th person.
Output
For each test case, output the answer in a line.