# BZOJ2844: albus就是要第一个出场(线性基)

Time Limit: 6 Sec  Memory Limit: 128 MB

Submit: 2054  Solved: 850

[Submit][Status][Discuss]

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]

## Source

```// luogu-judger-enable-o2
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#define int long long
using namespace std;
const int MAXN = 1e5 + 10, B = 61, mod = 10086;
char c = getchar(); int x = 0, f = 1;
while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar();}
while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
return x * f;
}
int N, a[MAXN], P[MAXN];
void Insert(int x) {
for(int i = B; i >= 0; i--) {
if((x >> i) & 1) {
if(!P[i]) {P[i] = x; return ;}
x = x ^ P[i];
}
}
}
void Gauss() {
for(int i = B; i >= 0; i--)
if(P[i])
for(int j = i + 1; j <= B; j++)
if((P[j] >> i) & 1)
P[j] ^= P[i];
}
int num = 0, pos[MAXN];
void ReMove() {
for(int i = 0; i <= B; i++)
if(P[i])
pos[++num] = i;
}
int fastpow(int a, int p) {
int base = 1;
while(p) {
if(p & 1) base = (base * a) % mod;
a = (a * a) % mod; p >>= 1;
}
return base;
}
main() {
#ifdef WIN32
freopen("a.in", "r", stdin);
#endif
for(int i = 1; i <= N; i++) a[i] = read(), Insert(a[i]);
Gauss();
ReMove();
int Q = read(), ans = 0;
for(int i = 1; i <= num; i++)
if((Q & (1ll << pos[i])))
ans = ans ^ (1 << i - 1);
printf("%lld\n", (ans * fastpow(2, N - num) + 1) % mod);
}```

1811 篇文章125 人订阅

0 条评论

## 相关文章

### CodeForces 666B World Tour(spfa+枚举)

B. World Tour time limit per test 5 seconds memory limit per test 512 mega...

35140

30050

### 1622: [Usaco2008 Open]Word Power 名字的能量

1622: [Usaco2008 Open]Word Power 名字的能量 Time Limit: 5 Sec  Memory Limit: 64 MB Su...

28540

18320

### 3016: [Usaco2012 Nov]Clumsy Cows

3016: [Usaco2012 Nov]Clumsy Cows Time Limit: 1 Sec  Memory Limit: 128 MB Submit:...

27950

### HDU 1250 Hat's Fibonacci

Hat's Fibonacci Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32...

362110

### POJ 2001 Shortest Prefixes

Description A prefix of a string is a substring starting at the beginning of th...

30990

35880

30620

### 2761: [JLOI2011]不重复数字（平衡树）

2761: [JLOI2011]不重复数字 Time Limit: 10 Sec  Memory Limit: 128 MB Submit: 2133  So...

28550