#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int vx=4e6+5, nx=1e6+5;
int n, dp[vx], f[vx], a[nx], ans;
int main()
{
cin.tie(NULL)->sync_with_stdio(false);
cin>>n;
for (int i=1; i<=n; i++) cin>>a[i];
for (int bit=0; bit<21; bit++)
{
ll cur=0, res=0, mod=(1<<(bit+1));
for (int i=1; i<=n; i++) f[a[i]%mod]++;
for (int i=0; i<(1<<bit); i++) cur+=f[i];
dp[0]=cur;
for (int i=1; i<mod; i++)
{
cur-=f[i-1];
cur+=f[(i+(1<<bit)-1)%mod];
dp[i]=cur;
}
//for (int i=0; i<mod; i++) cout<<"debug "<<bit<<' '<<i<<' '<<dp[i]<<'\n';
for (int i=1; i<=n; i++) res+=dp[(((-a[i])%mod)+mod)%mod];
if (res%2) ans+=(1<<bit);
for (int i=1; i<=n; i++) f[a[i]%mod]--;
}
cout<<ans;
}
/*
3 1 2 2
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
16 ms |
20816 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
262 ms |
14976 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
262 ms |
14976 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
16 ms |
20816 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
16 ms |
20816 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |