线性基

模板

#include <cstdio>
#include <iostream>
#include <algorithm>
#define int long long
using namespace std;
const int MAXN = 65; 
const int BIT = 62;

int n, base[MAXN];

void insert (int x) {
	for (int i = BIT; i >= 0; i--) {
		if ((1ll << i) & x) {
			if (base[i] == 0) {
				base[i] = x;
				break;
			} else x ^= base[i];
		}
	}
}

int Maxval () {
	int res = 0;
	for (int i = BIT; i >= 0; i--) {
		res = max (res, res ^ base[i]);
	}
	return res;
}

signed main () {
	scanf ("%lld", &n);
	for (int i = 1, x; i <= n; i++) {
		scanf ("%lld", &x);
		insert (x);	
	}
	printf ("%lld\n", Maxval ());
	return 0;
}
上一篇:Activiti 流程执行


下一篇:[Unity3D]多个摄像机进行场景的切换