O - XOR

You are given non-negative integers x, k. Please compute how many non-negative y satisfy y + (x xor y) = x + k. Here + is the usual addition and xor means bitwise exclusive-or. If there are infinitely many such y, please output -1.

Input

First line contains two integers x,k. (0 ≤ x, k ≤ 109)

Output

Output one line containing the answer.

Sample Input

3 24

Sample Output

4
#include<bits/stdc++.h>
using namespace std;
int main(){
	int x,k;int num=0;
	cin>>x>>k;
	if((k%2)!=0||(k/2&x)){
		cout<<0<<endl;
		return 0;
	}
	while(x){
		if(x&1) num++;
		x>>=1;
		
	}
	cout<<pow(2,num)<<endl;
	return 0;
}

这道题目异常简单,看代码就能明白。

但是一开始我用了pow函数,原形是float,有误差

所以应该直接移位。

不知道原形的不要随便用。

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值