TopH SUST Intra University Programming Contest 2019 Subset AND Solution


  

Problem Link : https://toph.co/p/subset-and

Solution in C++:

/// Author : AH_Tonmoy
#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
     int n , k , x  ;
     cin >> n >> k ;
      int ans = INT_MAX ;
     for ( int i = 0 ; i < n ; i++){
         cin >> x ;
         ans &= x ;
     }
    if ( ans < k ) cout <<"YES\n";
    else cout <<"NO\n";
  }
  return 0 ;
}

No comments

Most View Post

Recent post

Codeforces Round 971 (Div. 4) 2009C. The Legend of Freya the Frog Solution

  Problem Link    https://codeforces.com/contest/2009/problem/C S olution in C++: /// Author : AH_Tonmoy #include < bits / stdc ++. h &g...

Powered by Blogger.