-
Notifications
You must be signed in to change notification settings - Fork 1
/
BITDIFF.cpp
53 lines (46 loc) · 1.05 KB
/
BITDIFF.cpp
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
// BITDIFF - Bit Difference
// Author: Tarun Kumar
// E-mail: [email protected]
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define vll vector<ll>
#define f0(i,n) for(i=0;i<n;i++)
#define f1(i,n) for(i=1;i<=n;i++)
#define fab(i,a,b) for(i=a;i<=b;i++)
#define memo(a,b) memset(a,b,sizeof(a))
#define display(x) for(auto dsp:x)cout<<dsp<<" ";cout<<"\n";
#define ln "\n"
using namespace std;
int main()
{
FAST;
ll t,n,i,j,sum,tmp,it,x;
unordered_map<ll,ll> mappu;
cin>>t;
it=0;
while(t--)
{
it++;
cout<<"Case "<<it<<": ";
mappu.clear();
cin>>n;
ll a[n];
f0(i,n)
{
cin>>x;
bitset<33> bt(x);
f0(j,33)
mappu[j]+=bt[j];
}
sum=0;
for(auto it:mappu)
{
x=it.second;
tmp=x*(n-x)*2;
sum=(sum+tmp)%10000007;
}
cout<<sum<<ln;
}
return 0;
}