https://codeforces.com/problemset/problem/1365/E
思路:
k<=3的时候全选;
分析k>3的时候,如果某一位对答案有贡献,那么一定存在该位为1的串>=k-2个,比如k=7,最低位2^0有贡献,那么至少有5个串,而我们随机枚举3个串,必然在这5个串里面。
由此贪心
#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<map>
#include<set>
#include<cstdio>
#include<algorithm>
#define debug(a) cout<<#a<<"="<<a<<endl;
using namespace std;
const int maxn=550;
typedef long long LL;
inline LL read(){LL x=0,f=1;char ch=getchar(); while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}while (isdigit(ch)){x=x*10+ch-48;ch=getchar();}
return x*f;}
LL a[maxn];
int main(void){
cin.tie(0);std::ios::sync_with_stdio(false);
LL n;cin>>n;
for(LL i=1;i<=n;i++){
cin>>a[i];
}
LL ans=0;
for(LL i=1;i<=n;i++){
for(LL j=1;j<=n;j++){
for(LL k=1;k<=n;k++){
ans=max(ans,a[i]|a[j]|a[k]);
}
}
}
cout<<ans<<"\n";
return 0;
}