Advertisement
Ankit_132

D

Feb 14th, 2024
1,135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.60 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5.     int t;
  6.     cin>>t;
  7.    
  8.     while(t--){
  9.         int n;
  10.         cin>>n;
  11.        
  12.         vector<long long int> a(n);
  13.         for(auto &e: a)
  14.             cin>>e;
  15.            
  16.         long long int val = 0;
  17.        
  18.         for(auto e: a)
  19.             val ^= e;
  20.        
  21.         for(int b=60, chk=0; b>0; b--){
  22.             int cnt = 0;
  23.            
  24.             for(int i=0; i<n; i++)
  25.                 cnt += (((1ll<<b)&a[i])>0);
  26.                
  27.             if(cnt%2==0 && cnt>0)
  28.                 chk = 1;
  29.                
  30.             if(chk)     val |= (1ll<<b);
  31.         }
  32.        
  33.         cout<<val<<"\n";
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement