This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 7;
int n;
int a[N];
int main() {
#ifdef wws
freopen ("in.txt", "r", stdin);
#endif
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a[i];
}
int ans = 0;
for (int b = 0; b < 30; b++) {
vector<int> v;
int m = (1 << (b + 1));
for (int i = 0; i < n; i++) {
v.push_back(a[i] % m);
// cout << v.back() << ' ';
}
// cout << endl;
int cnt = 0;
for (int i = 0; i < n; i++) {
for (int j = i; j < n; j++) {
if ((v[i] + v[j]) % m >= m / 2) {
++cnt;
}
}
}
// cout << cnt << endl;
if (cnt & 1) {
ans += (1 << b);
}
}
cout << ans;
}
/*
m = 2^ (x+ 1)
bits: [0...b]
0 ... 2^b - 1
m - 1 >= vi + vj >= m / 2
*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |