题解:CF2162C Beautiful XOR
最多可以用
二进制从低到高按位考虑,如果第
::::success[CODE]
#include<bits/stdc++.h>
#define int long long
#define void inline void
using namespace std;
int T;
vector<int> ans;
signed main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> T;
while (T--) {
ans.clear();
int x, y;
cin >> x >> y;
for (int i = 0; (1ll << i) <= x; i++) {
if (((x >> i) & 1) ^ ((y >> i) & 1)) {
ans.push_back(1ll << i);
x ^= 1ll << i;
}
}
if (x != y) {
cout << -1 << '\n';
continue;
}
cout << ans.size() << '\n';
for (int i : ans) cout << i << ' ';
cout << '\n';
}
return 0;
}
::::