-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathXORSUB.cpp
More file actions
44 lines (41 loc) · 708 Bytes
/
Copy pathXORSUB.cpp
File metadata and controls
44 lines (41 loc) · 708 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
bool isxor[2000]; // if it is in the xor list
int xorlist[1000]; // the point to the next integer in the xorlist
int tmp;
int n,k;
inline void test()
{
register int idx=0; // the current free index of xorlist
register int i,j;
scanf("%d%d",&n,&k);
memset(isxor,0,sizeof(isxor));
isxor[k]=true;
xorlist[idx++]=k;
while(n--)
{
scanf("%d",&tmp);
for(i=0;i<idx;i++)
{
j=xorlist[i]^tmp;
if( !isxor[j] )
{
isxor[j]=true;
xorlist[idx++]=j;
}
}
}
for(i=1999;i>k && !isxor[i];i--);
printf("%d\n",i);
}
int main()
{
int t;
scanf("%d",&t);
while(t--)
test();
return 0;
}