#include <bits/stdc++.h>
using namespace std;
signed main(){
ios_base::sync_with_stdio(false);cin.tie(0);
long long n;
cin>>n;
long long arr[n];
for(int i = 0;i<n;i++){
cin>>arr[i];
}
long long all = 0;
for(int i = 0;i<=8;i++){
long long frq[(1<<(i+1))] = {0};
long long cnt = 0;
for(int j = 0;j<n;j++){
frq[arr[j]%((1<<(i+1)))]++;
}
for(int j = 0;j<(1<<(i+1));j++){
for(int e = j;e<(1<<(i+1));e++){
if((j+e)&(1<<i)){
if(j==e)cnt+=(frq[j]*frq[e]+frq[j])/2;
else cnt+=frq[j]*frq[e];
}
}
}
if(cnt&1)all+=(1<<i);
}
for(long long i = 9;i<30;i++){
vector<long long> v;
long long ans = 0;
for(int j = 0;j<n;j++){
if((arr[j]+arr[j])&(1LL<<i)){
ans++;
}
v.push_back(arr[j]%(1LL<<(i+1)));
}
sort(v.begin(),v.end());
for(int j = 0;j<n;j++){
long long l = (1LL<<i) , r = (1LL<<(i+1));
l-=arr[j] , r-=arr[j];
l%=(1LL<<(i+1));
r%=(1LL<<(i+1));
l+=(1LL<<(i+1));
r+=(1LL<<(i+1));
l%=(1LL<<(i+1));
r%=(1LL<<(i+1));
if(l<r){
ans += (lower_bound(v.begin(),v.end(),r)-v.begin())-(lower_bound(v.begin(),v.end(),l)-v.begin());
}else{
ans += (lower_bound(v.begin(),v.end(),r)-v.begin()) + (n-(lower_bound(v.begin(),v.end(),l)-v.begin()));
}
}
if(((ans/2)&1))all+=(1LL<<i);
}
cout<<all<<endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
17 ms |
340 KB |
Output is correct |
2 |
Correct |
17 ms |
456 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1656 ms |
24572 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1656 ms |
24572 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
17 ms |
340 KB |
Output is correct |
2 |
Correct |
17 ms |
456 KB |
Output is correct |
3 |
Correct |
612 ms |
3832 KB |
Output is correct |
4 |
Correct |
613 ms |
3872 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
17 ms |
340 KB |
Output is correct |
2 |
Correct |
17 ms |
456 KB |
Output is correct |
3 |
Execution timed out |
1656 ms |
24572 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |