0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-23 20:48:48 +00:00

D - Jzzhu and Numbers

https://codeforces.com/contest/449/submission/184326882
This commit is contained in:
Baoshuo Ren 2022-12-08 20:24:08 +08:00
parent a273b46d34
commit 088387d5e4
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A

52
Codeforces/449/449.cpp Normal file
View File

@ -0,0 +1,52 @@
#include <iostream>
using std::cin;
using std::cout;
const char endl = '\n';
const int mod = 1e9 + 7;
int n, s[1 << 20], ans;
int binpow(int a, int b) {
int res = 1;
while (b) {
if (b & 1) res = static_cast<long long>(res) * a % mod;
a = static_cast<long long>(a) * a % mod;
b >>= 1;
}
return res;
}
int main() {
std::ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n;
for (int i = 1, x; i <= n; i++) {
cin >> x;
s[(1 << 20) - 1 - x]++;
}
for (int i = 0; i < 20; i++) {
for (int j = 0; j < 1 << 20; j++) {
if (j & (1 << i)) {
s[j] += s[j ^ (1 << i)];
}
}
}
ans = binpow(2, n);
for (int i = 0; i < (1 << 20) - 1; i++) {
ans = (static_cast<long long>(ans) + (__builtin_popcount(i) % 2 ? -1 : 1) * binpow(2, s[i])) % mod;
}
cout << (ans + mod) % mod << endl;
return 0;
}