AhmedAshraff

Untitled

Nov 23rd, 2024
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.80 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #define boAshraf ios_base::sync_with_stdio(false); cin.tie(NULL);
  3. #define ll long long
  4. #define sz(s) (int)(s).size()
  5. #define all(s) (s).begin(),(s).end()
  6. using namespace std;
  7. void File();
  8. void sol();
  9. int main() {
  10.     boAshraf
  11.     File();
  12.     int t = 1;
  13.     cin >> t;
  14.     while (t--) {
  15.         sol();
  16.     }
  17.     return 0;
  18. }
  19.  
  20. void sol() {
  21.     int n,k;
  22.     cin>>n>>k;
  23.     vector<int>v(n);
  24.     for(auto &it:v)cin>>it;
  25.     int ans=0;
  26.     for(int i=0;i<=19;i++){
  27.         if((ans>>i)&1)continue;
  28.         for(auto it:v){
  29.             if((it>>i)&1){
  30.                 ans|=it;break;
  31.             }
  32.         }
  33.     }
  34.     cout<<ans<<'\n';
  35. }
  36.  
  37. void File() {
  38. // #ifndef ONLINE_JUDGE
  39.     freopen("looking.in", "r", stdin);
  40.     // freopen("output.txt", "w", stdout);
  41. // #endif
  42. }
Advertisement
Add Comment
Please, Sign In to add comment