Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define boAshraf ios_base::sync_with_stdio(false); cin.tie(NULL);
- #define ll long long
- #define sz(s) (int)(s).size()
- #define all(s) (s).begin(),(s).end()
- using namespace std;
- void File();
- void sol();
- int main() {
- boAshraf
- File();
- int t = 1;
- cin >> t;
- while (t--) {
- sol();
- }
- return 0;
- }
- void sol() {
- int n,k;
- cin>>n>>k;
- vector<int>v(n);
- for(auto &it:v)cin>>it;
- int ans=0;
- for(int i=0;i<=19;i++){
- if((ans>>i)&1)continue;
- for(auto it:v){
- if((it>>i)&1){
- ans|=it;break;
- }
- }
- }
- cout<<ans<<'\n';
- }
- void File() {
- // #ifndef ONLINE_JUDGE
- freopen("looking.in", "r", stdin);
- // freopen("output.txt", "w", stdout);
- // #endif
- }
Advertisement
Add Comment
Please, Sign In to add comment