题目大意:
最大异或和。
分析:
就是高斯消元一发,正确性很显然,模板题都懒得讲了
...
AC code:
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <algorithm>
#include <string>
#include <sstream>
#include <iostream>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <vector>
#define get(s, x) (((s)>>(x))&1)
#define pb push_back
#define mp make_pair
typedef long long LL;
typedef double DB;
typedef long double LD;
using namespace std;
const int MAXN = 109;
int n;
LL a[MAXN];
int main()
{
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
scanf("%d", &n);
for(int i = 1; i <= n; ++i)
cin >> a[i];
int st = 1;
for(int i = 63; i >= 0; --i)
{
bool flag = false;
for(int j = st; j <= n; ++j)
if(get(a[j], i))
{
swap(a[j], a[st]);
flag = true;break;
}
if(flag)
{
for(int j = 1; j <= n; ++j)
if(j != st && get(a[j], i))
a[j] ^= a[st];
st++;
}
}
LL ans = 0;
for(int i = 1; i <= n; ++i)
ans ^= a[i];
cout << ans << endl;
#ifndef ONLINE_JUDGE
fclose(stdin);
fclose(stdout);
#endif
return 0;
}