点击查看代码
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin>>n;
	vector<int> a(n);
	int res=0;
	for(int i=0;i<n;++i) {cin>>a[i];res^=a[i];}
	int x=0,y=0;
	int c=0;
	for(;res;res>>=1) c++;//res的最高位为右数第c位
	for(int i=0;i<n;++i) if(a[i]>>(c-1)&1) y^=a[i];
	else x^=a[i];
	cout<<x<<' '<<y<<"\n";
}

 posted on 2023-10-07 09:56  ruoye123456  阅读(15)  评论(0)    收藏  举报