Codeforces 631A Interview【模拟水题】

题意:

模拟模拟~~

代码:

#include<iostream>
using namespace std;
const int maxn = 1005;
int a[maxn], b[maxn], fa[maxn], fb[maxn];
int main (void)
{
    int n;cin>>n;
    for(int i = 1; i <= n; i++){
        cin>>a[i];
        if(i==1) fa[i] = a[i];
       else  fa[i] = fa[i-1]|a[i];
    }
    for(int i = 1; i <= n; i++){
        cin>>b[i];
        if(i==1) fb[i] = b[i];
        else fb[i] =fb[i - 1]| b[i];
    }
    long long res = 0;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= i; j++){
            long long t = fb[i] + fa[i] - fa[j-1] - fb[j -1];
            res = max(res, t);
        }
    }
    cout<<res<<endl;
    return 0;
}

你可能感兴趣的:(Codeforces 631A Interview【模拟水题】)