0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-30 18:56:26 +00:00
OI-codes/Luogu/P6102/P6102.cpp

29 lines
600 B
C++

#include <bits/stdc++.h>
using namespace std;
int n, x, y, xs, ys, sum;
unsigned int ans, a[500005];
int main() {
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
}
sum = n * n;
for (int i = 0; i < 32; i++) {
x = y = xs = ys = 0;
for (int j = 1; j <= n; j++) {
if ((a[j] >> i) & 1) xs++;
}
ys = n - xs;
for (int j = 1; j <= n; j++) {
x = xs * n + ys * xs;
y = ys * n + xs * ys;
}
ans += (x * y + (sum - x) * (sum - y)) << i;
}
cout << ans << endl;
return 0;
}