-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAndOrUnion.cpp
More file actions
48 lines (36 loc) · 782 Bytes
/
Copy pathAndOrUnion.cpp
File metadata and controls
48 lines (36 loc) · 782 Bytes
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
#include<bits/stdc++.h>
using namespace std;
//directives
#define pb push_back
#define int long long
#define ss second
#define ff first
void solve(){
int n;
cin>>n;
vector<int> arr(n);
for(int i=0; i<n; i++) cin>>arr[i];
vector<int> cnt(32, 0);
for(int i=0; i<32; i++){
for(int j=0; j<n; j++){
// cout<<arr[j]<<" "<<(arr[j] & (1 << i))<<endl;
cnt[i] += (arr[j] & (1 << i)) == 0 ? 0 : 1;
}
}
int ans = 0;
for(int i=0; i<32; i++){
// cout<<i<<" "<<cnt[i]<<endl;
if(cnt[i] > 1){
ans += (1 << i);
}
}
cout<<ans<<endl;
}
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
int t=1;
cin>>t;
while(t--) solve();
return 0;
}