이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
signed main(){
ios_base::sync_with_stdio(false);cin.tie(0);
int n;
cin>>n;
int arr[n];
for(int i = 0;i<n;i++){
cin>>arr[i];
}
long long all = 0;
/*
for(int i = 0;i<8;i++){
int frq[(1<<i)] = {0};
for(int j = 0;j<n;j++){
frq[arr[j]&((1<<i)-1)]++;
}
int cnt = 0;
for(int j = 0;j<(1<<i);j++){
for(int e = 0;e<(1<<i);e++){
if((j+e)&(1<<i)){
cnt+=frq[j]*frq[e];
}
}
}
if(cnt&1)all+=(1<<i);
}*/
for(long long i = 0;i<30;i++){
vector<long long> v;
for(int j = 0;j<n;j++){
v.push_back(arr[j]%(1LL<<(i+1)));
}
sort(v.begin(),v.end());
long long ans = 0;
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&1)all+=(1<<i);
}
cout<<all<<endl;
}
# | 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... |