CF2160C.Reverse XOR
普及-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Given a positive integer x, let f(x) be the positive integer formed by reversing the binary representation of x without leading zeroes. For example, if x=12=11002, then f(x)=00112=3.
You are given an integer n. Please determine if there exists a positive integer x such that x⊕f(x)=n∗.
∗Here, ⊕ denotes the bitwise XOR operation.
给定一个正整数 x,令 f(x) 为将 x 的二进制表示(不含前导零)反转后所得到的正整数。例如,若 x=12=11002,则 f(x)=00112=3。
你将获得一个整数 n。请判断是否存在正整数 x,使得 x⊕f(x)=n∗。
∗此处,⊕ 表示按位异或运算。
输入格式
Each test contains multiple test cases. The first line contains the number of test cases t (1≤t≤104). The description of the test cases follows.
The first line of each test case contains an integer n (0≤n<230).
每个测试包含多个测试用例。第一行包含测试用例的数量 t(1≤t≤104)。随后是各测试用例的描述。
每个测试用例的第一行包含一个整数 n(0≤n<230)。
输出格式
For each test case, output YES if there exists a positive integer x such that x⊕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.
对于每个测试用例,如果存在正整数 x 使得 x⊕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=1, f(x)=1, and x⊕f(x)=0. Thus, the answer is YES.
In the second case, when x=2, f(x)=1, and x⊕f(x)=3. Thus, the answer is YES.
In the fourth test case, we can show there is no x that satisfies x⊕f(x)=8, so the answer is NO.
第一种情况,当 x=1 时,f(x)=1,且 x⊕f(x)=0。因此答案为 YES。
第二种情况,当 x=2 时,f(x)=1,且 x⊕f(x)=3。因此答案为 YES。
第四组测试用例中,可以证明不存在满足 x⊕f(x)=8 的 x,因此答案为 NO。
输入解题思路,AI测评打分。不知道怎么写?