如题解:
#include<cstdio> #include<cstdlib> #include<cstring> #include<string> #include<algorithm> #include<iostream> #include<queue> #include<map> #include<cmath> #include<set> #include<stack> #define ll long long #define pb push_back #define max(x,y) ((x)>(y)?(x):(y)) #define min(x,y) ((x)>(y)?(y):(x)) #define cls(name,x) memset(name,x,sizeof(name)) #define fs first #define sc second #define mp make_pair #define L(x) (1<<x) #define next Next #define index Index using namespace std; const int inf=1e9+10; const ll llinf=1e17+10; const int maxn=2e5+10; const int maxm=5e1+10; const int maxk=29; const int mod=1e9+7; int n; int A[maxn],B[maxn]; int num[maxm][maxn]; int solve(int temp[],int x)//返回数组中小于x的个数 { int pos=lower_bound(temp+1,temp+1+n,x)-temp; return pos-1; } int main() { //freopen("in.txt","r",stdin); while(~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]); for(int i=0;i<=maxk;i++) for(int j=1;j<=n;j++) num[i][j]=B[j]%(L(i+1)); for(int i=0;i<=maxk;i++) sort(num[i]+1,num[i]+1+n); int ans=0; for(int k=0;k<=maxk;k++) { ll c=0; for(int i=1;i<=n;i++) { int a=A[i]%(L(k+1)); c+=solve(num[k],2*L(k)-a)-solve(num[k],L(k)-a); c+=solve(num[k],4*L(k)-a)-solve(num[k],3*L(k)-a); } if(c%2==1) ans+=L(k); } printf("%d ",ans); } return 0; }