比赛 26暑假集训模拟赛1 评测结果 AAAAAAAAAA
题目名称 异或加密 最终得分 100
用户昵称 exil 运行时间 1.323 s
代码语言 C++ 内存使用 9.40 MiB
提交时间 2026-06-29 09:46:58
显示代码纯文本
#include<bits/stdc++.h>
using namespace std;
#define int long long
int ming[1000005];
int an[1000005];
signed main(){
    freopen("XORcipher.in","r",stdin);
    freopen("XORcipher.out","w",stdout);
    int n;
    cin>>n;
    int maxx=0;
    string a="";
    for(int i = 1;i<=n;i++){
        scanf("%lld",&ming[i]);
        maxx=max(maxx,ming[i]);
    }
    for(int i = 1;i<=n;i++){
        scanf("%lld",&an[i]);
        maxx=max(maxx,an[i]);
    }
    
    int r=0;
    while(maxx!=0){
        maxx/=2;
        r++;
    }
    for(int i = 0;i<r;i++){
        int yi1=0,yi2=0;
        for(int j = 1;j<=n;j++){
            if((ming[j]>>i)%2==1)yi1++;
            if((an[j]>>i)%2==1)yi2++;
            
        }
        if(yi1==yi2){
            a=a+"0";
        }
        else a=a+"1";
        
    }
    //cout<<a;
    int ans=0;
    int w=1;
    for(int i = 0;i<r;i++){
        if(a[i]=='1')ans+=w;
        w*=2;
    }
    printf("%lld",ans);
    return 0;
}