-
Notifications
You must be signed in to change notification settings - Fork 0
/
C.cpp
37 lines (36 loc) · 736 Bytes
/
C.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
//Took help from editorial
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
int main()
{
fastio;
long long n,m,i,j,a[205],b[205],c=0,count,mask;
cin>>n>>m;
for(i=0;i<n;i++)
cin>>a[i];
for(i=0;i<m;i++)
cin>>b[i];
for(mask=0;mask<(1<<9);mask++)
{
count=0;
for(i=0; i<n; i++)
{
for(j=0; j<m; j++)
{
c=a[i]&b[j];
if((c&mask)==c)
{
count++;
break;
}
}
}
if(count==n)
{
cout<<mask<<"\n";
break;
}
}
return 0;
}