Http://codeforces.com/problemset/problem/631/A
Give two sets of arrays of the same length a0~n-1 b0~n-1 to find the maximum value of a continuous element in a bitwise OR (or) and the maximum value of a continuous element in B or (or)
Or operation of the words encountered a new number only add or unchanged, will not be reduced, so directly put all the number of bits or, then sum can be
#include<bits/stdc++.h>
using namespace std;
int n;
vector<int> a;
vector<int> b;
int main(){
while(~scanf("%d", &n)){
a.clear();
b.clear();
for(int i = 0; i < n; i++){
int temp;
scanf("%d", &temp);
a.push_back(temp);
}
for(int i = 0; i < n; i++){
int temp;
scanf("%d", &temp);
b.push_back(temp);
}
vector<int>::iterator it;
int ans1 = 0;
for(it = a.begin(); it != a.end(); it++){
ans1 = ans1|(*it);
}
int ans2 = 0;
for(it = b.begin(); it != b.end(); it++){
ans2 = ans2|(*it);
}
int ans = ans1+ans2;
printf("%d\n", ans);
}
return 0;
}
"Codeforces" 631A interview