题意:给定a+b的和,以及a和b的异或,问有多少组这样的(a,b)
思路:百度到a+b=(a&b)*2+a^b,那么显然我们就可以把a&b的值求出来,那么根据a&b和a^b就可以统计出对数,另外注意的是当s==x的时候要特判减去2对包含0的情况
#include <cstdio>
#include <queue>
#include <cstring>
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <set>
#include <ctime>
#include <cmath>
#include <cctype>
using namespace std;
#define maxn 100000
#define LL long long
int cas=1,T;
int main()
{
LL s,x;
while (scanf("%lld%lld",&s,&x)!=EOF)
{
int flag = 0;
if (s==x)
flag=1;
s-=x;
if (s%2==1)
{
puts("0");
continue;
}
s/=2;
LL ans = 1;
for (int i = 0;i<60;i++)
{
int x1=(s>>i)&1;
int x2=(x>>i)&1;
if (x1==1 && x2==1)
{
puts("0");
return 0;
}
if (x2==1)
ans*=2;
}
if (!flag)
printf("%lld\n",ans);
else
printf("%lld\n",ans-2);
}
//freopen("in","r",stdin);
//scanf("%d",&T);
//printf("time=%.3lf",(double)clock()/CLOCKS_PER_SEC);
return 0;
}