

CoprimeTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 3749 Accepted Submission(s): 1443 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 3peoplegroups 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 ith person. Output For each test case, output the answer in a line. Sample Input
Sample Output
Source  
