Skip to content

Instantly share code, notes, and snippets.

@satylogin
Last active April 6, 2018 15:05
Show Gist options
  • Save satylogin/925f3c74d234765f9b86e118a8294f42 to your computer and use it in GitHub Desktop.
Save satylogin/925f3c74d234765f9b86e118a8294f42 to your computer and use it in GitHub Desktop.
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ll long long int
#define ld long double
#define pb push_back
#define mkp make_pair
#define pii pair<int, int>
#define pll pair<long long int, long long int>
#define sci(x) scanf("%d", &x)
#define scl(x) scanf("%lld", &x)
#define fi first
#define sc second
#define eps 1e-9
ll B[40], P[100001];
int main()
{
ios_base::sync_with_stdio(false);cout.tie(0);cin.tie(0);
ll t, n, i, j, k, x, y, z;
P[0] = 1;
for (i = 1; i <= 100000; ++i) P[i] = (2 * P[i-1]) % MOD;
cin >> t;
while (t--) {
memset(B, 0, sizeof(B));
cin >> n;
for (j = 0; j < n; ++j) {
cin >> x;
for (i = 0; i < 32; ++i) {
if ((x>>i)&1) B[i] += 1;
}
}
ll ans = 0;
for (i = 0; i < 32; ++i) {
ll tmp = (P[n] - P[n-B[i]] + MOD) % MOD;
ans = (ans + P[i] * tmp) % MOD;
}
cout << ans << endl;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment