http://codeforces.com/contest/627/problem/A
题意:
两个数a,b a+b=s a xor b= x
给出s,x 问有多少对a,b满足条件
首先有个结论,(其实自己也能推出来,但自己太菜没想出来)
拥有这个公式后,这道题变得简单了些,移项后求出
a&b = (s - x) / 2,并且判断是否合法
a ^ b 我们已经知道,那么只需要通过a&b,确定一下a,b
如果 那么 ai = bi, 那么 ai = bi = ai&bi,此时a,b已确定为1种
那么 ai&bi = 0 否则无解,此时a,b可为1,0 或0,1 所以答案*2
当s==x 会有 (0,x) (x,0)不合法答案 减2
#include<bits/stdc++.h>
#define fi first
#define se second
#define log2(a) log(n)/log(2)
#define show(a) cout<<a<<endl;
#define show2(a,b) cout<<a<<" "<<b<<endl;
#define show3(a,b,c) cout<<a<<" "<<b<<" "<<c<<endl;
#define tim printf("Time cost : %lf s\n",(double)clock()/CLOCKS_PER_SEC);
using namespace std;
typedef long long ll;
typedef long long LL;
typedef pair<int, int> P;
typedef pair<P, ll> LP;
const ll inf = 1e9+100;
const int N = 1e6 + 10;
const ll mod = 1e9+7;
const int base = 131;
const double pi = acos ( -1 );
const double eps = 1e-8;
inline ll mul(ll x,ll y) { return (x*y-(ll)((long double)x*y/mod)*mod+mod)%mod;}
inline ll ksm(ll a,ll b) {ll ans=1;while(b){if(b&1)ans=mul(ans,a);a=mul(a,a),b>>=1;}return ans;}
#define a(i,j) a[(i-1)*m+(j)]
#define b(i,j) b[(i-1)*m+(j)]
unordered_map<ll, ll> mp;
ll n, m,x,y,z,cx,k;
ll ans;
ll a[N],b[N],c[N],vis[N],pos[N];
set<ll> st;
P p[N];
ll sum,cnt,flag;
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
ll s,x;
cin>>s>>x;
ll ad=(s-x)>>1;
if((s-x)%2!=0||s<x) flag=1;
ans=1;
for(int i=0;i<=60;i++)
{
if((x>>i)&1)
{
if((ad>>i)&1)
{
flag=1;
break;
}
else ans<<=1;
}
}
if(s==x) ans-=2;
if(flag) cout<<0;
else cout<<ans<<endl;
}