// Source: https://usaco.guide/general/io
#include <bits/stdc++.h>
using namespace std;
int n, a[1000005];
int main() {
cin >> n;
for (int i = 1; i <= n; i++) cin >> a[i];
int ans = 0;
for (int i = 0; i < 30; i++) {
vector <int> v;
for (int j = 1; j <= n; j++) {
v.push_back(a[j] % (1ll<<(i + 1)));
}
sort(v.begin(), v.end());
long long tmp = 0;
for (int j = 1; j <= n; j++) {
int x = a[j] % (1ll<<(i + 1));
int l = (1ll<<i) - x, r = (1ll<<(i + 1)) - 1 - x;
if(l >= 0) tmp += upper_bound(v.begin(), v.end(), r) - lower_bound(v.begin(), v.end(), l);
else {
tmp += v.end() - lower_bound(v.begin(), v.end(), l + (1ll<<(i + 1)));
tmp += upper_bound(v.begin(), v.end(), r) - v.begin();
}
//cout << tmp << ' ';
}
//cout << tmp << '\n';
//tmp /= 2;
if (tmp & 1) ans ^= (1ll<<i);
}
cout << ans;
}
| # | 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... |