102383: [AtCoder]ABC238 D - AND and SUM

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Score : $400$ points

Problem Statement

Solve the following problem for $T$ test cases.

Given are non-negative integers $a$ and $s$. Is there a pair of non-negative integers $(x,y)$ that satisfies both of the conditions below?

  • $x\ \text{AND}\ y=a$
  • $x+y=s$
What is bitwise $\mathrm{AND}$?

The bitwise $\mathrm{AND}$ of integers $A$ and $B$, $A\ \mathrm{AND}\ B$, is defined as follows:

  • When $A\ \mathrm{AND}\ B$ is written in base two, the digit in the $2^k$'s place ($k \geq 0$) is $1$ if those of $A$ and $B$ are both $1$, and $0$ otherwise.
For example, we have $4\ \mathrm{AND}\ 6 = 4$ (in base two: $100\ \mathrm{AND}\ 110 = 100$).

Constraints

  • $1 \leq T \leq 10^5$
  • $0 \leq a,s \lt 2^{60}$
  • All values in input are integers.

Input

Input is given from Standard Input. The first line is in the following format:

$T$

Then, $T$ test cases follow. Each test case is in the following format:

$a$ $s$

Output

Print $T$ lines. The $i$-th line $(1 \leq i \leq T)$ should contain Yes if, in the $i$-th test case, there is a pair of non-negative integers $(x,y)$ that satisfies both of the conditions in the Problem Statement, and No otherwise.


Sample Input 1

2
1 8
4 2

Sample Output 1

Yes
No

In the first test case, some pairs such as $(x,y)=(3,5)$ satisfy the conditions.

In the second test case, no pair of non-negative integers satisfies the conditions.


Sample Input 2

4
201408139683277485 381410962404666524
360288799186493714 788806911317182736
18999951915747344 451273909320288229
962424162689761932 1097438793187620758

Sample Output 2

No
Yes
Yes
No

Input

题意翻译

给出两个数 $a,b$,问能否找到两个数 $x$ 和 $y$ 使得 $x+y=a$ 且 $x\ \operatorname{and}\ y=b$。 多组数据询问。

Output

得分:400分

问题描述

对于$T$个测试用例,解决以下问题。

给定非负整数$a$和$s$。是否存在一对非负整数$(x,y)$,同时满足以下两个条件?

  • $x\ \text{AND}\ y=a$
  • $x+y=s$
什么是按位与?

整数$A$和$B$的按位与$A\ \mathrm{AND}\ B$定义如下:

  • 当$A\ \mathrm{AND}\ B$用二进制表示时,第$2^k$位($k \geq 0$)为$1$,当$A$和$B$的该位均为$1$时,否则为$0$。
例如,我们有$4\ \mathrm{AND}\ 6 = 4$(用二进制表示:$100\ \mathrm{AND}\ 110 = 100$)。

约束条件

  • $1 \leq T \leq 10^5$
  • $0 \leq a,s \lt 2^{60}$
  • 输入中的所有值都是整数。

输入

输入从标准输入给出。第一行是以下格式:

$T$

接着,$T$个测试用例跟在后面。每个测试用例是以下格式:

$a$ $s$

输出

打印$T$行。第$i$行$(1 \leq i \leq T)$应包含Yes,如果在第$i$个测试用例中,存在一对非负整数$(x,y)$同时满足问题描述中的两个条件,否则包含No


样例输入1

2
1 8
4 2

样例输出1

Yes
No

在第一个测试用例中,存在一些满足条件的对$(x,y)$,例如$(x,y)=(3,5)$。

在第二个测试用例中,不存在一对非负整数满足条件。


样例输入2

4
201408139683277485 381410962404666524
360288799186493714 788806911317182736
18999951915747344 451273909320288229
962424162689761932 1097438793187620758

样例输出2

No
Yes
Yes
No

加入题单

算法标签: