Ankit_132

Boxes

Jun 21st, 2023
334
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.56 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.     {
  10.         int n;
  11.         cin>>n;
  12.        
  13.         vector<long long int> a(n);
  14.         for(auto &e: a)
  15.             cin>>e;
  16.            
  17.         int maxBit = 0;
  18.        
  19.         for(auto e: a)
  20.         {
  21.             for(int b=0; b<61; b++)
  22.             {
  23.                 if(((1ll<<b) & e) > 0)
  24.                     maxBit = max(maxBit, b);
  25.             }
  26.         }
  27.        
  28.         int cnt = 0;
  29.        
  30.         for(auto e: a)
  31.             cnt += (((1ll<<maxBit) & e) > 0);
  32.            
  33.         cout<<(cnt + 1)/2<<"\n";
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment