bzoj2844 albus就是要第一个出场
传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=2844
【题解】
考虑$n$个数组成的基,大小为$k$,那么每种方案都有$2^{n-k}$可以取到。
观察样例也能发现这个结论。
然后就是正常的线性基统计,最后乘一个$2^{n-k}$,加一即可。
# include <stdio.h> # include <string.h> # include <iostream> # include <algorithm> // # include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef unsigned long long ull; const int N = 1e5 + 10, LG = 30; const int mod = 10086; # define bit(x, i) (((x) >> (i)) & 1) int n, a[N], m, T; int L[LG + 5], Lbase[LG + 5]; int ans = 0; int main() { cin >> n; for (int i=1; i<=n; ++i) scanf("%d", a+i); cin >> T; for (int i=1; i<=n; ++i) { int t = a[i]; for (int j=30; ~j; --j) { if(!bit(t, j)) continue; if(!Lbase[j]) { Lbase[j] = t; break; } t ^= Lbase[j]; } } m = 0; for (int i=0; i<31; ++i) if(Lbase[i]) L[++m] = i; for (int i=1; i<=m; ++i) { if(!bit(T, L[i])) continue; ans += (1<<i-1) % mod; ans %= mod; } for (int i=n-m; i>=1; --i) { ans <<= 1; ans %= mod; } ++ans; if(ans >= mod) ans -= mod; cout << ans << endl; return 0; }