惨不忍睹,不能多说了。直接看代码吧。。。
就是暴力了。。。
#include <cstdio>
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
using namespace std;
#define N 100020
int a[N<<1], n;
vector<int> c[22];
int f[1<<21];
int main() {
#ifndef ONLINE_JUDGE
freopen("in.txt", "r", stdin);
#endif
for (int i=0; i<22; i++) c[i].clear();
int cnt, T;
for (int i=0; i<(1<<21); i++) {
cnt = 0;
for (int j=0; j<21; j++) if (i & (1<<j)) cnt++;
c[cnt].push_back(i);
}
scanf("%d", &T);
while (T--) {
scanf("%d", &n);
memset(f, 0, sizeof(f));
bool ok = false;
for (int i=0; i<n; i++) {
scanf("%X", &a[i]);
if (++f[a[i]] >= 2) ok = true;
}
if (ok) { puts("0") ; goto foo;}
for (int i=1; i<21; i++)
for (int j=0; j<n; j++)
for (int k=0; k<c[i].size(); k++) {
if (f[a[j] ^ c[i][k]]) {
printf("%d\n", i);
goto foo;
}
}
foo:
;
}
return 0;
}