CF2153B.Bitwise Reversion

入门

通过率:0%

时间限制:1.50s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are given three non-negative integers xx, yy and zz. Determine whether there exist three non-negative integers aa, bb and cc satisfying the following three conditions:

  • a&b=xa \mathbin{\&} b = x
  • b&c=yb \mathbin{\&} c = y
  • a&c=za \mathbin{\&} c = z

where &\mathbin{\&} denotes the bitwise AND operation.

给你三个非负整数 xx、yy 和 zz。判断是否存在三个非负整数 aa、bb 和 cc,满足以下三个条件:

  • a&b=xa \mathbin{\&} b = x
  • b&c=yb \mathbin{\&} c = y
  • a&c=za \mathbin{\&} c = z

其中 &\mathbin{\&} 表示按位与运算。

输入格式

Each test contains multiple test cases. The first line contains the number of test cases tt (1≤t≤1041 \le t \le 10^4). The description of the test cases follows.

The first and only line of each test case contains three integers xx, yy and zz (0≤x,y,z≤1090\le x, y, z\le 10^9) — the target values of a&ba \mathbin{\&} b, b&cb \mathbin{\&} c and a&ca \mathbin{\&} c, respectively.

每个测试包含多个测试用例。第一行包含测试用例的数量 tt(1≤t≤1041 \le t \le 10^4)。随后是各测试用例的描述。

每个测试用例仅有一行,包含三个整数 xx、yy 和 zz(0≤x,y,z≤1090\le x, y, z\le 10^9),分别表示 a&ba \mathbin{\&} b、b&cb \mathbin{\&} c 和 a&ca \mathbin{\&} c 的目标值。

输出格式

For each test case, output "YES" if there exists three non-negative integers aa, bb, and cc satisfying the above conditions, and "NO" otherwise.

You can output the answer in any case (upper or lower). For example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as positive responses.

对于每个测试用例,若存在三个非负整数 aa、bb 和 cc 满足上述条件,则输出 "YES";否则输出 "NO"。

你可以以任意大小写形式输出答案(大写或小写均可)。例如,字符串 "yEs"、"yes"、"Yes" 和 "YES" 均会被识别为肯定回答。

输入输出样例

  • 输入#1

    5
    1 1 1
    3 2 6
    4 8 12
    9 10 12
    12730 3088 28130

    输出#1

    YES
    YES
    NO
    YES
    NO

说明/提示

In the first test case, a=3a = 3, b=5b = 5, and c=9c = 9 satisfies the condition as 3&5=13 \mathbin{\&} 5 = 1, 5&9=15 \mathbin{\&} 9 = 1, and 3&9=13 \mathbin{\&} 9 = 1.

In the second test case, a=7a = 7, b=3b = 3, and c=22c = 22 satisfies the condition as 7&3=37 \mathbin{\&} 3 = 3, 3&22=23 \mathbin{\&} 22 = 2, and 7&22=67 \mathbin{\&} 22 = 6.

In the third test case, it can be proven that there are no three non-negative integers aa, bb, and cc such that a&b=4a \mathbin{\&} b = 4, b&c=8b \mathbin{\&} c = 8, and a&c=12a \mathbin{\&} c = 12.

在第一个测试用例中,a=3a = 3、b=5b = 5、c=9c = 9 满足条件,因为 3&5=13 \mathbin{\&} 5 = 1,5&9=15 \mathbin{\&} 9 = 1,且 3&9=13 \mathbin{\&} 9 = 1。

在第二个测试用例中,a=7a = 7、b=3b = 3、c=22c = 22 满足条件,因为 7&3=37 \mathbin{\&} 3 = 3,3&22=23 \mathbin{\&} 22 = 2,且 7&22=67 \mathbin{\&} 22 = 6。

在第三个测试用例中,可以证明:不存在三个非负整数 aa、bb、cc,使得 a&b=4a \mathbin{\&} b = 4、b&c=8b \mathbin{\&} c = 8 且 a&c=12a \mathbin{\&} c = 12。

输入解题思路,AI测评打分。不知道怎么写?

首页