Ankit_132

Possible or Not

Jun 14th, 2023
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.72 KB | None | 0 0
  1.  
  2. #include <bits/stdc++.h>
  3.  
  4. using namespace std;
  5.  
  6. #define ll     long long
  7. #define _test   int _TEST; cin>>_TEST; while(_TEST--)
  8. #define ff     first
  9. #define ss     second
  10. #define pb     push_back
  11. #define ppb    pop_back
  12.  
  13. int main()
  14. {
  15.     ios_base::sync_with_stdio(false);
  16.     cin.tie(NULL);
  17.     cout.tie(NULL);
  18.  
  19.     _test
  20.     {
  21.         int n, b;
  22.         cin>>n>>b;
  23.  
  24.         vector<int> a(n);
  25.         for(auto &e: a)
  26.             cin>>e;
  27.  
  28.         int ok=0;
  29.  
  30.         ll int x = ((1ll)<<30) - 1;
  31.  
  32.         for(auto e: a)
  33.         {
  34.             if((e&b) == b)
  35.                 x &= e, ok=1;
  36.         }
  37.  
  38.         if(x == b && ok)
  39.             cout<<"YES\n";
  40.         else
  41.             cout<<"NO\n";
  42.     }
  43. }
  44.  
Advertisement
Add Comment
Please, Sign In to add comment