提交记录
快疯了,就 WA#45 一个点。
#include<bits/stdc++.h>
#define LL long long
using namespace std;
const int N = 4e5 + 10;
LL a, b, c, cnt, js,ans1,ans2;
int main()
{
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
cin >> a >> b >> c;
LL C = c;
while (C) cnt+=(C&1),C>>=1ll,js++;
if (a + b > (js<<1ll) + cnt) return cout << -1, 0;
if (abs(cnt-(a+b))&1ll) return cout << -1, 0;
LL x=(a+b-cnt)>>1ll;
LL A=a-x,B=b-x;
C=c;js=0ll;
while(C){
LL j=(LL)(1ll<<js);
if(C&1){
if(A>=B&&A) A--,ans1=(LL)ans1+j;
else if(B>=A&&B) B--,ans2+=j;
else return cout<<-1,0;
}
else{
if(x) x--,ans1+=j,ans2+=j;
}
js++;
C>>=1;
}
if(x){
for(int i=1;i<=x;i++)
ans1+=(1ll<<js),ans2+=(1ll<<js),js++;
}
if(ans1^ans2==c&&__builtin_popcountll(ans1)==a&&__builtin_popcountll(ans2)==b)
cout<<ans1<<' '<<ans2;
else cout<<-1;
return 0;
}