John is a manager of a CPU chip factory, the factory produces lots of chips everyday. To manage large amounts of products, every processor has a serial number. More specifically, the factory produces nn chips today, the ii-th chip produced this day has a serial number sisi.
At the end of the day, he packages all the chips produced this day, and send it to wholesalers. More specially, he writes a checksum number on the package, this checksum is defined as below:
which i,j,ki,j,k are three different integers between 11 and nn. And ⊕⊕ is symbol of bitwise XOR.
Can you help John calculate the checksum number of today?
Input
The first line of input contains an integer TT indicating the total number of test cases.
The first line of each test case is an integer nn, indicating the number of chips produced today. The next line has nn integers s1,s2,..,sns1,s2,..,sn, separated with single space, indicating serial number of each chip.
1≤T≤1000
3≤n≤1000
0≤si≤109
There are at most 1010 testcases with n>100
Output
For each test case, please output an integer indicating the checksum number in a line.
Sample Input
2 3 1 2 3 3 100 200 300
Sample Output
6 400
题意:n个数中选取三个数,求
思路:打死我也想不到是暴力?可能是赛后放宽了时限9秒??真的是随便写了。。。反正随手一个暴力就A了。。。
#include<bits/stdc++.h>
#define CaseT int t;scanf("%d",&t);while(t--)
#define ms(a,x) memset(a,x,sizeof(a))
using namespace std;
#define N 107
#define MAX 100002
typedef long long ll;
int a[MAX];
void solve(){
int n;
scanf("%d",&n);
for(int i=0;i<n;i++)
cin>>a[i];
int ans=0;
for(int i=0;i<n;i++){
for(int j=i+1;j<n;j++){
for(int k=j+1;k<n;k++){
ans=max(ans,(a[i]+a[j])^a[k]);
ans=max(ans,(a[i]+a[k])^a[j]);
ans=max(ans,(a[k]+a[j])^a[i]);
}
}
}
cout<<ans<<endl;
}
int main(){
CaseT
solve();
return 0;
}