// #include <bits/stdc++.h>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <map>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <set>
#include <deque>
#include <numeric>
#include <stack>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
void fast_io() {
// freopen("", "r", stdin);
// freopen("", "w", stdout);
ios::sync_with_stdio(0);
cin.tie();
cout.tie();
cout << setprecision(9);
}
#define int long long
#define endl '\n'
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define fi first
#define se second
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
const int N = 4e3 + 5;
int C[N] = {};
void solve() {
int n; cin >> n;
int a[n + 1];
for (int i = 1; i <= n; i++) cin >> a[i];
if (n < N){
int ans = 0;
for (int i = 1; i <= n; i++){
for (int j = i; j <= n; j++){
// cout << '(' << i << " , " << j << ") : " << i << " + " << j << " = " << i + j << endl;
int x = a[i]; x += a[j];
ans = (ans ^ x);
}
}
cout << ans << endl;
return;
}
int ans = 0;
for (int i = 1; i <= n; i++) C[a[i]]++;
for (int i = 1; i <= 2 * N; i++){
for (int j = 1; j < i; j++){
int x = j, y = i - j;
if (x >= N or y >= N) continue;
if (x > y) break;
if (x != y){
int c = C[x] * C[y];
if (c % 2) ans = (ans ^ i);
}
else {
int c = (C[x] * (C[y] - 1)) / 2 + C[x];
if (i == 12 && j == 3) cout << c << endl;
if (c % 2) ans = (ans ^ i);
}
}
}
cout << ans << endl;
}
signed main() {
fast_io();
srand(chrono::steady_clock::now().time_since_epoch().count());
int tc = 1;
// cin >> tc;
while (tc--) solve();
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... |