-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCF_1395C.cpp
57 lines (51 loc) · 1010 Bytes
/
CF_1395C.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <functional>
#include <cstdlib>
#include <list>
#include <iomanip>
#define ll long long
using namespace std;
int main() {
int n, m;
cin >> n >> m;
vector<int> a;
vector<int> b;
for (int i = 0; i < n; i++) {
int num;
cin >> num;
a.push_back(num);
}
for (int i = 0; i < m; i++) {
int num;
cin >> num;
b.push_back(num);
}
int MAX_LIMIT = pow(2, 9) - 1;
int minim = INT_MAX;
for (int i = 0; i <= MAX_LIMIT; i++) {
int curr = i;
bool isPossible = false;
for (int j = 0; j < a.size(); j++) {
isPossible = false;
for (int k = 0; k < b.size(); k++) {
if (((a[j] & b[k]) | curr) == curr) {
isPossible = true;
break;
}
}
if (!isPossible) break;
}
if (isPossible) {
minim = min(minim, curr);
}
}
cout << minim << endl;
}