# Bzoj2844 albus就是要第一个出场

Time Limit: 6 Sec  Memory Limit: 128 MB
Submit: 1113  Solved: 471

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

## Source

 1 #include<iostream>
2 #include<cstdio>
3 #include<algorithm>
4 using namespace std;
5 const int mxn=100010;
6 const int mod=10086;
8     int x=0,f=1;char ch=getchar();
9     while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
10     while(ch>='0' && ch<='9'){x=x*10-'0'+ch;ch=getchar();}
11     return x*f;
12 }
13 int n,q,c;
14 int a[mxn];
15 int main(){
16     int i,j,k;
20     k=1;
21     for(i=31;i>=0 && k<=n;i--){
22         int p=k;
23         for(j=k;j<=n;j++)
24             if(a[j]&(1<<i)){p=j;break;}
25         if(p!=k)swap(a[p],a[k]);
26         if((a[k]&(1<<i))==0)continue;
27         for(j=1;j<=n;j++){
28             if(j==k)continue;
29             if(a[j]&(1<<i))a[j]^=a[k];
30         }
31         k++;
32     }
33     k--;
34 //    printf("%d\n",k);
35     int res=0;
36     int ans=0;
37     for(i=1;i<=k;i++){
38         if((res^a[i])<=q){
39             res^=a[i];
40             ans=(ans+(1<<(k-i)))%mod;
41         }
42     }
43     for(i=1;i<=n-k;i++)ans=ans*2%mod;
44     ans=(ans+1)%mod;
45     printf("%d\n",ans);
46     return 0;
47 }

posted @ 2017-01-22 22:30  SilverNebula  阅读(104)  评论(0编辑  收藏  举报