시도 횟수: 1회
해결한 시간: 00:15
<aside> 💡
$A$ →$B$를 가기 위해선 $A$에만 켜져있는 비트를 꺼야하고 $B$에만 켜져있는 비트를 켜야한다.
이때 XOR하는 값은 $A$보다 작거나 같아야 하므로 우선 $B$에만 있는 비트를 켜 $A$를 크게 만든다.
그 후 $A$에만 켜져 있었던 비트를 끈다.
이 과정에서 $A<x$인 경우가 발생하면 불가능한 경우이다.
</aside>
#include <bits/stdc++.h>
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
using namespace std;
typedef long long ll;
ll a, b;
void solve()
{
ll ans1 = 0ll;
ll ans2 = 0ll;
cin >> a >> b;
for(int i = 0; i<=31; i++){
if(!(a&(1LL<<i)) && (b&(1LL<<i))){
ans1 |= (1LL<<i);
}
}
for(int i = 0; i<=31; i++){
if((a&(1LL<<i)) && !(b&(1LL<<i))){
ans2 |= (1LL<<i);
}
}
if(ans1>a){
cout << "-1\\n";
return;
}
a ^= ans1;
if(ans2>a){
cout << "-1\\n";
return;
}
cout << "2\\n";
cout << ans1 <<" " << ans2 <<"\\n";
// bitset<4>(9);
}
signed main()
{
FASTIO;
int _tc; cin >> _tc;
while (_tc--) solve();
return 0;
}