测评会员优惠活动进行中 · 开通 VIP,有效期内测评不限次 VIP 优惠中 · 测评不限次 立即查看

A10203. XOR Equation

编程题 普及/提高-

题目描述

Two positive integers $a$ and $b$ have a sum of $s$ and a bitwise XOR of $x$ . How many possible values are there for the ordered pair $(a,b)$ ?

输入格式

The first line of the input contains two integers $s$ and $x$ ( $2<=s<=10^{12}$ , $0<=x<=10^{12}$ ), the sum and bitwise xor of the pair of positive integers, respectively.

输出格式

Print a single integer, the number of solutions to the given conditions. If no solutions exist, print $0$ .

输入输出样例

输入 #1
9 5
输出 #1
4
输入 #2
3 3
输出 #2
2
输入 #3
5 2
输出 #3
0

说明/提示

In the first sample, we have the following solutions: $(2,7)$ , $(3,6)$ , $(6,3)$ , $(7,2)$ .

In the second sample, the only solutions are $(1,2)$ and $(2,1)$ .
上一题 去做题 下一题