In this

**HackerEarth Subset AND problem solution**, You are given a number Z and a set S with N elements. Your job is to find a sub-set of S such that the AND of the given number and this subset is zero. If this subset is possible print "Yes" otherwise print "No"## HackerEarth Subset AND problem solution.

`#include <bits/stdc++.h>`

using namespace std;

int main()

{

int t,n,k,x;

cin >> t;

while ( t-- ) {

cin >> k >> n;

int ans = k;

for ( int i = 0; i < n; i++ ) {

cin >> x;

ans = (ans & x);

}

if ( ans == 0 ) cout << "Yes" << endl;

else cout << "No" << endl;

}

return 0;

}

## 0 Comments