有个结论:一个可异或得到的数,用原来
n
个数异或得到它都有
知道这个就做完了。
#include<cstdio>
#include<algorithm>
using namespace std;
const int MOD=10086;
typedef long long LL;
int n,m;
LL b[70],tmp[70],ans;
void Insert(LL x){
for(int j=60;j>=0;j--) if((x>>j)&1){
if(b[j]) x^=b[j]; else{
b[j]=x;
break;
}
}
}
LL Pow(LL a,int b){
LL res=1;
for(;b;b>>=1,a=a*a%MOD) if(b&1) res=(res*a)%MOD;
return res;
}
int main(){
freopen("bzoj2844.in","r",stdin);
freopen("bzoj2844.out","w",stdout);
scanf("%d",&n);
for(int i=1;i<=n;i++){
LL x; scanf("%lld",&x);
Insert(x);
}
scanf("%d",&m);
for(int i=0;i<=60;i++) if(b[i]) tmp[++tmp[0]]=i;
for(int i=1;i<=tmp[0];i++) if((m>>tmp[i])&1) ans+=(1LL<<i-1);
printf("%d\n",(ans%MOD*Pow(2,n-tmp[0])%MOD+1)%MOD);
return 0;
}