# 【BZOJ2844】albus就是要第一个出场

3
1 2 3
1

## Sample Output

3

N = 3, A = [1 2 3]
S = {1, 2, 3}
2^S = {空, {1}, {2}, {3}, {1, 2}, {1, 3}, {2, 3}, {1, 2, 3}}
f(空) = 0
f({1}) = 1
f({2}) = 2
f({3}) = 3
f({1, 2}) = 1 xor 2 = 3
f({1, 3}) = 1 xor 3 = 2
f({2, 3}) = 2 xor 3 = 1
f({1, 2, 3}) = 0

B = [0, 0, 1, 1, 2, 2, 3, 3]

## HINT

1 <= N <= 10,0000

#include <cstdio>
#include <cstring>
#include <iostream>
#define mod 10086
using namespace std;
const int maxn=100010;
int n,m,tot,ans,sum;
int v[maxn];
int main()
{
scanf("%d",&n);
int i,j;
for(i=1;i<=n;i++)	scanf("%d",&v[i]);
scanf("%d",&m);
if(m==0)
{
printf("1");
return 0;
}
for(i=1<<30;i;i>>=1)
{
for(j=++tot;j<=n;j++)	if(v[j]&i)
{
swap(v[tot],v[j]);
break;
}
if(!(v[tot]&i))
{
tot--;
continue;
}
for(j=1;j<=n;j++)	if((v[j]&i)&&j!=tot)	v[j]^=v[tot];
}
for(i=1;i<=tot;i++)	if((sum^v[i])<m)	sum^=v[i],ans|=(1<<tot-i);
ans=(ans+1)%mod;
for(i=1;i<=n-tot;i++)	ans<<=1,ans%=mod;
printf("%d",(ans+1)%mod);
return 0;
}

| 欢迎来原网站坐坐！ >原文链接<

posted @ 2017-06-18 15:57  CQzhangyu  阅读(274)  评论(0编辑  收藏  举报