-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcf449d.cpp
More file actions
37 lines (31 loc) · 764 Bytes
/
cf449d.cpp
File metadata and controls
37 lines (31 loc) · 764 Bytes
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
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int MOD = 1000000007;
const int N = (1 << 20) + 9;
int c[N] , n , a[N] , p[N] , s[N];
int main() {
cin >> n;
for (int i = 0 ; i < n ; i ++) {
cin >> a[i];
c[a[i]] ++;
}
p[0] = 1;
for (int i = 1 ; i < N ; i ++) {
p[i] = p[i - 1] * 2 % MOD;
s[i] = s[i >> 1] + (i & 1);
}
for (int i = 0 ; i < 20 ; i ++) {
for (int j = 0 ; j < (1 << 20) ; j ++) {
if(j & (1 << i))
c[j - (1 << i)] += c[j];
}
}
LL ans = p[n];
for (int i = 1 ; i < (1 << 20) ; i ++) {
if (s[i] & 1) ans -= p[c[i]];
else ans += p[c[i]];
}
cout << (ans % MOD + MOD) % MOD << endl;
return 0;
}