問題一覧 > 通常問題

No.3150 count X which satisfies with equlation

レベル : / AI推定難易度 : 140 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 127
作問者 : Cafe1942 / テスター : kazuppa sclara
お気に入りにしたユーザー ProblemId : 12265 / 自分の提出
問題文最終更新日: 2025-05-20 22:21:35
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
Math Cafe 1 (順位表) の他の問題:

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もしくは右上の雲マークをクリックしてアカウントを作成してください。