1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
| #include <iostream> #include <algorithm> #include <cstdio> #include <vector>
using namespace std;
typedef long long ll;
const int N = 100010; const int M = 70; const ll mod = 1000000007;
int n, vis[N]; ll a[N], r[M], b[M], d[M]; vector<ll> v;
ll power(ll a, int n, ll p) { ll res = 1; while (n) { if (n & 1) res = (res * a) % p; a = (a * a) % p; n >>= 1; } return res % p; }
bool insert(ll x, ll b[]) { for (int k = 63; k >= 0; k--) { if (x >> k & 1) { if (b[k]) x ^= b[k]; else { b[k] = x; return true; } } } return false; }
int main() { while (scanf("%d", &n) != EOF) { int cr = 0; v.clear(); for (int i = 0; i < M; i++) r[i] = b[i] = 0; for (int i = 1; i <= n; i++) { vis[i] = 0; scanf("%lld", &a[i]); if (insert(a[i], r)) { cr++; vis[i] = 1; v.push_back(a[i]); } } if (cr == n) { printf("0\n"); continue; } for (int i = 1; i <= n; i++) { if (vis[i]) continue; insert(a[i], b); } ll res = (n - cr) * power(2, n - cr - 1, mod) % mod; int len = (int)v.size(); for (int i = 0; i < len; i++) { int cd = 0; for (int k = 0; k <= 63; k++) d[k] = 0; for (int k = 0; k < len; k++) { if (i == k) continue; if (insert(v[k], d)) cd++; } for (int k = 0; k <= 63; k++) if (b[k] && insert(b[k], d)) cd++; if (!insert(v[i], d)) res = (res + power(2, n - cd - 1, mod)) % mod; } printf("%lld\n", res); } return 0; }
|