No.3150 count X which satisfies with equlation
Problem Statement
Output the total number of non-negative integers $X$ that satisfy $A$ $|$ $X$ $=$ $B$.
Here, $|$ denotes the bitwise OR in binary representation; for example, $(5)_{10} | (6)_{10} = (101)_2 | (110)_2 = (111)_2 = (7)_{10}$.
What is OR?
For numbers $a$ , $b$ each of which is either $0$ or $1$, $a$ | $b$ is defined as $1$ if at least $1$ of $a$ and $b$ is $1$, and $0$ otherwise.Constraints
- $0 \leq A,B \leq 255$
- All input values are integers.
Input
The input is given from standard input in decimal in the following format.$A$ $B$
Output
Output the number of non-negative integers $X$ that satisfy the equation.
Sample
Sample 1
Input
0 6
Output
1
The $X$ satisfying $ (0)_{10}$ $|$ $X$ $=$ $(6)_{10}$ is only 1 value, $(6)_{10}$.
$X$ $=$ $(6)_{10}$ satisfies the given equation because $(0)_{10}$ $|$ $(6)_{10}$ $=$ $(6)_{10}$.
No other non-negative integer $X$ satisfies the equation, so output $1$.
Sample 2
Input
1 5
Output
2
The non-negative integers $X$ satisfying $(1)_{10}$ $|$ $X$ $=$ $(5)_{10}$ are the following $2$: $(4)_{10}$ and $(5)_{10}$.
Sample 3
Input
3 4
Output
0
No non-negative integer $X$ satisfies $(3)_{10}$ $|$ $X$ $=$ $(4)_{10}$.
Sample 4
Input
29 31
Output
16
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
Cafe1942
kazuppa