#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll MAXN=4e6+6;
const ll logN=22;
ll n,ans;
ll a[MAXN];
ll pref[2][MAXN];
int main()
{
cin>>n;
for(ll i=1;i<=n;i++)
{
cin>>a[i];
}
for(ll j=0;j<logN;j++)
{
//cout<<j<<endl;
memset(pref,0,sizeof(pref));
for(ll i=1;i<=n;i++)
{
if(a[i]&(1<<j))
{
pref[1][a[i]%(1<<j)]++;
}
else
{
pref[0][a[i]%(1<<j)]++;
}
}
for(ll j=1;j<MAXN;j++)
{
pref[0][j]+=pref[0][j-1];
pref[1][j]+=pref[1][j-1];
}
ll cnt=0;
for(ll i=1;i<=n;i++)
{
ll t=a[i]%(1<<j);
if(a[i]&(1<<j))
{
if((1<<j)-t-1>=0)cnt+=pref[0][(1<<j)-t-1];
cnt+=pref[1][MAXN-1]-pref[1][(1<<j)-t-1];
}
else
{
if((1<<j)-t-1>=0)cnt+=pref[1][(1<<j)-t-1];
cnt+=pref[0][MAXN-1]-pref[0][(1<<j)-t-1];
}
if((a[i]*2)&(1<<j))cnt++;
}
//cout<<j<<" "<<cnt<<endl;
if((cnt/2)%2==1)ans+=(1<<j);
}
cout<<ans<<endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
485 ms |
63212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1057 ms |
75240 KB |
Output is correct |
2 |
Correct |
1020 ms |
74732 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1057 ms |
75240 KB |
Output is correct |
2 |
Correct |
1020 ms |
74732 KB |
Output is correct |
3 |
Correct |
1296 ms |
77680 KB |
Output is correct |
4 |
Correct |
1235 ms |
77036 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
485 ms |
63212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
485 ms |
63212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |