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

P6102 [EER2]谔运算

R54857077
This commit is contained in:
Baoshuo Ren 2021-08-03 14:31:11 +08:00 committed by Baoshuo Ren
parent 59b7cf75f3
commit aa714607b4
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

View File

@ -0,0 +1,28 @@
#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;
}