CF76D Plus and xor 题解
题目主要与加、异或两种运算有关,那么我们就先把两种运算的计算方法列出来。
| 1,1 | 1,0 | 0,1 | 0,0 | |
|---|---|---|---|---|
| 加 | 0(进一位) | 1 | 1 | 0 |
| 异或 | 0 | 1 | 1 | 0 |
可以发现只有在两数当前位均为一时,加法进一位,异或不进位,其他时候两种运算计算方法是相同的。
所以,由于题目中说
对于
那么什么时候无解呢?由于输出格式中讲到
#include<iostream>
#include<cmath>
using namespace std;
int main(){
unsigned long long int a,b;//坑点
cin>>a>>b;
if(a>=b && (a-b)%2==0) cout<<(a-b)/2<<' '<<a-(a-b)/2;
else cout<<-1;
}