My issue
My code
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t, n;
int b;
cin >> t;
while(t--){
cin >> n >> b;
int arr[n];
int element;
int k = (1<<31)-1;
for(int i = 0; i < n; i++){
cin >> element;
if((element & b) == b){ // checks whether element is a super mask of b.
k &= element;
}
}
if(k == b)
cout << "yes\n";
else
cout << "no\n";
}
return 0;
}
Problem Link: CS2023_PON Problem - CodeChef
when i initialize k= (1<<30)-1 it gives wrong answer can anyone tell why?