I xay loves or
题意
问存在多少个 y y y 使得 $x\ or\ y = s $
逐个按位讨论即可
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define int ll
#define rep(i, j, k) for (ll(i) = (j); (i) <= (k); (++i))
typedef long long ll;
signed main() {
int x, s;
cin >> x >> s;
if (x > s)
return cout << 0 << endl, 0;
int ans = 1;
rep(i, 0, 30) {
if (!((s >> i) & 1) and ((x >> i) & 1))
return cout << 0 << endl, 0;
if (((s >> i) & 1) and ((x >> i) & 1))
ans <<= 1;
}
cout << ans - (x == s) << endl;
return 0;
}