CF2160C.Reverse XOR

普及-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

Given a positive integer xx, let f(x)f(x) be the positive integer formed by reversing the binary representation of xx without leading zeroes. For example, if x=12=11002x=12=1100_2, then f(x)=00112=3f(x)=0011_2=3.

You are given an integer nn. Please determine if there exists a positive integer xx such that x⊕f(x)=nx \oplus f(x) = n∗^{\text{∗}}.

∗^{\text{∗}}Here, ⊕\oplus denotes the bitwise XOR operation.

给定一个正整数 xx,令 f(x)f(x) 为将 xx 的二进制表示(不含前导零)反转后所得到的正整数。例如,若 x=12=11002x = 12 = 1100_2,则 f(x)=00112=3f(x) = 0011_2 = 3。

你将获得一个整数 nn。请判断是否存在正整数 xx,使得 x⊕f(x)=nx \oplus f(x) = n∗^{\text{∗}}。

∗^{\text{∗}}此处,⊕\oplus 表示按位异或运算。

输入格式

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 line of each test case contains an integer nn (0≤n<2300 \leq n \lt 2^{30}).

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

每个测试用例的第一行包含一个整数 nn(0≤n<2300 \leq n \lt 2^{30})。

输出格式

For each test case, output YES if there exists a positive integer xx such that x⊕f(x)=nx \oplus f(x) = n, and NO otherwise.

You can output the answer in any case. For example, the strings "yEs", "yes", and "Yes" are also recognized as positive responses.

对于每个测试用例,如果存在正整数 xx 使得 x⊕f(x)=nx \oplus f(x) = n,则输出 YES;否则输出 NO。

你可以以任意大小写形式输出答案。例如,字符串 "yEs"、"yes" 和 "Yes" 同样被视为肯定回答。

输入输出样例

  • 输入#1

    6
    0
    3
    6
    8
    10
    11

    输出#1

    YES
    YES
    YES
    NO
    YES
    NO

说明/提示

In the first case, when x=1x=1, f(x)=1f(x)=1, and x⊕f(x)=0x \oplus f(x)=0. Thus, the answer is YES.

In the second case, when x=2x=2, f(x)=1f(x)=1, and x⊕f(x)=3x \oplus f(x)=3. Thus, the answer is YES.

In the fourth test case, we can show there is no xx that satisfies x⊕f(x)=8x \oplus f(x)=8, so the answer is NO.

第一种情况,当 x=1x=1 时,f(x)=1f(x)=1,且 x⊕f(x)=0x \oplus f(x)=0。因此答案为 YES。

第二种情况,当 x=2x=2 时,f(x)=1f(x)=1,且 x⊕f(x)=3x \oplus f(x)=3。因此答案为 YES。

第四组测试用例中,可以证明不存在满足 x⊕f(x)=8x \oplus f(x)=8 的 xx,因此答案为 NO。

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

首页