题目大意
给你连个数u v你需要找出一个数组a使得a1a2a3^ … ^an =u 并且 a1 + a2 + … + an = v
我们知道^运算不会改变操作数的奇偶性,并且如果a&b == 0则a^b =a+b反之是a 和b mod2的和,
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
long long n, m;
cin >> n >> m;
if (n > m || (n % 2) != (m % 2)) {
cout << -1 << endl;
return 0;
}
if (n == m) {
if (n == 0) {
cout << 0 << endl;
return 0;
}
else {
cout << 1 << endl << n << endl;
return 0;
}
}
long long x = (m - n) / 2;
if ((x & n) != 0) {
cout << 3 << endl;
cout << n << " " << x << " " << x << endl;
return 0;
}
else {
cout << 2 << endl;
cout << (x ^ n) << " " << x << endl;
return 0;
}
return 0;
}