思路:
这道题主要考察的是玄学位运算,
并且我们要知道,$2^{0}+2^{1}+...+2^{n}=2^{n+1}-1$
所以我们只要将这些数字转化为二进制的形式,从高位往低位扫下去就行。
代码:
#include<iostream>
#include<cstring>
#include<cstdio>
#define R register
using namespace std;
typedef long long ll;
const ll N=1000010;
/*inline ll read(){
ll x=0,t=1;
char ch=getchar();
while(ch<'0' || ch>'9') {
t=-1;
ch=getchar();
}
while(ch>='0' && ch<='9'){
x=x*10+(ch-'0');
ch=getchar();
}
return x*t;
}*/
ll n,a[N];
int main(){
freopen("sword.in","r",stdin);
freopen("sword.out","w",stdout);
scanf("%lld",&n);
for(R ll i=1;i<=n;i++)
scanf("%lld",&a[i]);
ll ans=0,t=0;
for(R ll i=30;i>=0;i--){
t=0;
for(R ll j=1;j<=n;j++)
if((ans&a[j])==ans && (a[j]&(1<<i))!=0) t++;
if(t>=2) ans+=(1<<i);
}
printf("%lld",ans);
}