-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathb.cpp
36 lines (33 loc) · 849 Bytes
/
b.cpp
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
#include <bits/stdc++.h>
#define endl '\n'
#define eat cin
#define moo cout
#define int long long
using namespace std;
int T, N, a[2000];
vector<int> o, e;
int32_t main(){
eat.tie(0) -> sync_with_stdio(0);
eat >> T;
while(T--){
o.clear(), e.clear();
eat >> N;
for(int i = 0; i < N; i++){
eat >> a[i];
if(a[i] % 2) o.push_back(a[i]);
else e.push_back(a[i]);
}
int ans = (int)o.size() * (int)e.size();
for(int i = 0; i < (int)o.size(); i++){
for(int j = i+1; j < (int)o.size(); j++){
if(gcd(o[i], o[j]) > 1) ans++;
}
}
for(int i = 0; i < (int)e.size(); i++){
for(int j = i+1; j < (int)e.size(); j++){
ans++;
}
}
moo << ans << endl;
}
}