Codeforces Round #344 (Div. 2) A. Interview

题意:

给你2*n的矩阵

然后定义一个函数f(a,l,r)表示a数组在l到r的或值

然后让你找到一对l,r,使得f(a,l,r)+f(b,l,r)最大

思路:

直接或所有数

 1 #include<cstdio>
 2 #include<cstring>
 3 #include<algorithm>
 4 #include<iostream>
 5 #include<cstdlib>
 6 #include<string>
 7 #include<cmath>
 8 #include<vector>
 9 using namespace std;
10 const int maxn=1e5+7;
11 const double eps=1e-8;
12 const double pi=acos(-1);
13 #define ll long long
14 const int MOD = 10000;
15 
16 int n;
17 
18 int main()
19 {
20     scanf("%d",&n);
21     ll ans=0;
22     ll x=0;
23     for(int i=0; i<n; i++)
24     {
25         ll y;
26         scanf("%I64d",&y);
27         x|=y;
28     }
29     ans+=x;
30     x=0;
31     for(int i=0; i<n; i++)
32     {
33         ll y;
34         scanf("%I64d",&y);
35         x|=y;
36     }
37     ans+=x;
38     printf("%I64d
",ans);
39     return 0;
40 }
View Code
原文地址:https://www.cnblogs.com/ITUPC/p/5243785.html