fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. typedef long long ll;
  4. const int Mod=1e9+7;
  5. const ll INF = 10000000000000;
  6. const int N = 1e6+7;
  7.  
  8. void solve() {
  9. int n,l;
  10. cin >> n >> l;
  11. vector<vector<int>> a(l,vector<int>(2,0));
  12. for(int i=0;i<n;i++){
  13. int x;cin >> x;
  14. for(int j=0;j<l;j++){
  15. int bit =(x>>j)&1;
  16. a[j][bit]+=1;
  17. }
  18. }
  19. ll y=0;
  20. for(int i=0;i<l;i++){
  21. if(a[i][1]>a[i][0]) y+=1<<i;
  22. }
  23. cout << y << '\n';
  24. }
  25. int main(){
  26. ios::sync_with_stdio(false);
  27. cin.tie(nullptr);
  28.  
  29. int t;
  30. cin >> t;
  31. while (t--) solve();
  32.  
  33. return 0;
  34. }
Success #stdin #stdout 0.01s 5320KB
stdin
7
3 5
18 9 21
3 5
18 18 18
1 1
1
5 30
1 2 3 4 5
6 10
99 35 85 46 78 55
2 1
0 1
8 8
5 16 42 15 83 65 78 42
stdout
17
18
1
1
39
0
2