本题是比赛的签到题,线下赛共计 个队伍通过。
- 定理 :。
证明:对于任意一个正整数对其他正整数做按位与(且)运算,它在二进制下相应位的 不可能变为 ,但相应位的 存在变为 的可能(只需与其按位与的数相应位为 即可)。
- 定理 :。
证明:对于在二进制下的任意位,如果已经为 则一定还为 ,为 则一定也只能还为 。
那么,总结一下两个定理,得出 。
从两个数拓展到 个数可以显然证明结论不变。
代码:
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int maxn=159;
int t,ans,n;
signed main(){
ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
for(cin>>t;t--;ans=0){
cin>>n;
for(int i=1,x;i<=n;i++)cin>>x,ans=max(ans,x);
cout<<ans<<'\n';
}
}