#include <bits/stdc++.h>
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
using namespace std;
#define int long long int
const int N = 4e3 + 100;
const int md = 1e9 + 7;
const int INF = 1e9;
int32_t main(int32_t argc, char *argv[]) {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int T = 1;
// cin >> T;
while (T--) {
int n;
cin >> n;
if (n <= 4e3) {
vector<int> a(n);
for (int i = 0; i < n; i++)
cin >> a[i];
int ans = 0;
for (int i = 0; i < n; i++)
for (int j = i; j < n; j++)
ans ^= (a[i] + a[j]);
cout << ans << '\n';
} else {
vector<int> a(n), cnt(N);
for (int i = 0; i < n; i++) {
cin >> a[i];
cnt[a[i]]++;
}
int ans = 0;
for (int i = 1; i < N; i++) {
for (int j = 1; j < N; j++) {
if ((i != j && cnt[j] > 0 && cnt[i] > 0) || (i == j && cnt[i] >= 2)) {
if (((cnt[j] - (i == j)) & 1) && ((cnt[i] - (i == j)) & 1)) {
int x = i + j;
for (int k = 0; k < 30; k++)
if (((1 << k) & x)) {
ans ^= (1 << k);
}
}
}
}
cnt[i] = 0;
}
for (int i = 0; i < n; i++)
ans ^= (a[i] + a[i]);
cout << ans << '\n';
}
}
return 0;
}
# | 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... |