You are given two integer sequences, each of length Na1,…,aN and b1,…,bN.

There are N2 ways to choose two integers i and j such that 1≤i,jN. For each of these N2 pairs, we will compute ai+bj and write it on a sheet of paper. That is, we will write N2 integers in total.

Compute the XOR of these N2 integers.

 

Definition of XOR

 

Constraints

 

  • All input values are integers.
  • 1≤N≤200,000
  • 0≤ai,bi<228

Input

 

Input is given from Standard Input in the following format:

N
a1 a2 … aN
b1 b2 … bN

Output

 

Print the result of the computation.

Sample Input 1

 

2
1 2
3 4

Sample Output 1

 

2

On the sheet, the following four integers will be written: 4(1+3),5(1+4),5(2+3)and 6(2+4).

Sample Input 2

 

6
4 6 0 0 3 3
0 5 6 5 0 3

Sample Output 2

 

8

Sample Input 3

 

5
1 2 3 4 5
1 2 3 4 5

Sample Output 3

 

2

Sample Input 4

 

1
0
0

Sample Output 4

 

0

 

初看本题时以为 本题有又是一道找规律的亦或题目

但是当把表打出来之后发现这是并不能轻易的推出规律

看了题解用了半天才真正理解了这道题

对于本题的暴力方法一定是不行的

那么我们考虑按位来得出答案

我们对每个b对1<<m 取余

在对所有的a[i]+b[j]中进行二分

若啊a[i]+b[j]在mod/2的一倍和二倍之间

或者三倍和四倍之间 他对这一位就是一 

如果跑完一遍发现这一位中有n个1

那么我们这ans中的这一位就是1

否则就是零

代码

#include<bits/stdc++.h>
using namespace std;
int a[200005];
int b[200005];
vector<int> ve;
int main()
{
    int ans=0;
    int n;
    scanf("%d",&n);
    for(int i=1; i<=n; i++)
        scanf("%d",&a[i]);
    for(int i=1; i<=n; i++)
        scanf("%d",&b[i]);
    long long tmp=0;
    for(int i=0; i<=29; i++)
    {
        ve.clear();
        int mod=(1<<(i+1));
        for(int j=1; j<=n; j++)
            ve.push_back(b[j]%mod);
        mod/=2;
        sort(ve.begin(),ve.end());
        tmp=0;
        for(int j=1; j<=n; j++)
        {
            int tmpl,tmpr;
            tmpl=lower_bound(ve.begin(),ve.end(),mod*1-a[j]%(mod*2))-ve.begin()-1;
            tmpr=lower_bound(ve.begin(),ve.end(),mod*2-a[j]%(mod*2))-ve.begin()-1;
            tmp+=tmpr-tmpl;
            tmpl=lower_bound(ve.begin(),ve.end(),mod*3-a[j]%(mod*2))-ve.begin()-1;
            tmpr=lower_bound(ve.begin(),ve.end(),mod*4-a[j]%(mod*2))-ve.begin()-1;
            tmp+=tmpr-tmpl;
        }
        if(tmp%2==1) ans=(1<<i)|ans;
    }
    printf("%d\n",ans);

}