-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1535B.cpp
More file actions
64 lines (57 loc) · 1.27 KB
/
1535B.cpp
File metadata and controls
64 lines (57 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <functional>
#include <set>
#include <queue>
#include <sstream>
#include <numeric>
using namespace std;
using p = pair<int, int>;
using ll = long long;
const int MAX = 10e+6;
const int INF = 0x66554433;
vector<string> split(string input, char delimiter) {
vector<string> answer;
stringstream ss(input);
string temp;
while (getline(ss, temp, delimiter)) {
answer.push_back(temp);
}
return answer;
}
inline void Quick_IO(){
ios_base :: sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
}
int main(){
Quick_IO();
int t;
cin>>t;
while(t--){
int n;
cin>>n;
vector<int> arr;
for(int i = 0;i<n;i++){
int a;
cin>>a;
if(a%2==1) arr.push_back(a);
}
sort(arr.begin(), arr.end(), [](int a, int b){
return a>b;
});
int counts=0;
for (int i = 0; i < (int)arr.size(); ++i) {
for (int j = i+1; j < (int)arr.size(); ++j) {
if(gcd(arr[i], 2*arr[j])==1){
counts++;
}
}
}
cout<<(n*(n-1))/2-counts<<"\n";
}
return 0;
}