#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main()
{
int t=1;
// cin>>t;
while(t--)
{
int n;
cin>>n;
int a[n],c[n];
for(int i=0;i<n;i++)
{
cin>>a[i];
}
int pw=1,fnl=0;
for(int j=0;j<21;j++)
{
pw*=2;
for(int i=0;i<n;i++)c[i]=a[i]%pw;
sort(c,c+n);
// we want sum to be [pw/2 , pw-1]
int on=0;
for(int i=0;i<n;i++)
{
for(int k=i;k<=i;k++)
{
// maximum
int sx=(c[i]+c[k]);
if((pw/2)<=sx and sx<pw)
{
on++;
}
if(pw+(pw/2)<=sx and sx<2*pw)
{
on++;
}
}
// l <= c[i] + c[k] < r
// l-c[i] <= c[k]
int l=pw/2,r=pw;
on+=lower_bound(c,c+n,r-c[i])-lower_bound(c,c+n,l-c[i]);
l=(l+r);
r=(r+r);
on+=lower_bound(c,c+n,r-c[i])-lower_bound(c,c+n,l-c[i]);
// c[k] < r-c[i]
}
on/=2;
if(on&1)fnl+=pw/2;
}
cout<<fnl<<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... |