蒟蒻的第一篇题解…
大佬勿喷
题目大意
给定含有个整数的整数数列,求,,且可以重复选。
分析
前置芝士:与运算
如果我们想要让更大,那我们就需要让和的二进制形式尽量相同。但是题中说了,可以重复选。显而易见,我们只需要把数列中的最大值再与(&)上自身就可以了。
AC CODE:
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int T;
int n;
ll ans;
ll Max(ll a,ll b){//求最大值
return a>b?a:b;
}
ll fread(){//快读
ll x=0;
char ch=getchar();
while(ch<'0' || ch>'9'){
ch=getchar();
}
while(ch>='0' && ch<='9'){
x=(x<<1)+(x<<3)+(ch^48);
ch=getchar();
}
return x;
}
void fwrite(ll x){//快写
if(x>9){
fwrite(x/10);
}
putchar(x%10+'0');
}
int main(){
T=fread();//输入
while(T--){
n=fread();
for(int i=1;i<=n;i++){//求最大值
ans=Max(ans,fread());
}
fwrite(ans);
puts("");
ans=0;
}
return 0;
}