CF2187B.Shortest Statement Ever
普及+/提高
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given two non-negative integers x, y. Find two non-negative integers p and q such that p&q=0, and ∣x−p∣+∣y−q∣ is minimized. Here, & denotes the bitwise AND operation.
给你两个非负整数 x、y。请找出两个非负整数 p 和 q,使得 p&q=0,且 ∣x−p∣+∣y−q∣ 最小。其中,& 表示按位与运算。
输入格式
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 only line of each test case contains two non-negative integers x and y (0≤x,y<230).
每个测试包含多个测试用例。第一行包含测试用例的数量 t(1≤t≤104)。随后是各测试用例的描述。
每个测试用例仅有一行,包含两个非负整数 x 和 y(0≤x,y<230)。
输出格式
For each test case, output two non-negative integers p and q you found. If there are multiple pairs of p and q satisfying the conditions, you may output any of them.
It can be proven that under the constraints of the problem, any valid solution satisfies max(p,q)<231.
对于每个测试用例,输出你找到的两个非负整数 p 和 q。如果存在多组满足条件的 p 和 q,你可以输出其中任意一组。
可以证明,在本题的约束条件下,任何合法解均满足 max(p,q)<231。
输入输出样例
输入#1
7 0 0 1 1 3 6 7 11 4 4 123 321 1073741823 1073741822
输出#1
0 0 2 1 3 8 6 9 4 3 128 321 1073741824 1073741822
说明/提示
In the first test case, one valid pair would be p=0 and q=0, as 0&0=0 and ∣x−p∣+∣y−q∣=∣0−0∣+∣0−0∣=0 is the minimum over all pairs of p and q.
In the third test case, one valid pair would be p=3 and q=8, as 3&8=0 and ∣x−p∣+∣y−q∣=∣3−3∣+∣8−6∣=2 is the minimum over all pairs of p and q. Note that (p,q)=(3,4) is also a valid pair.
在第一个测试用例中,一个有效的数对是 p=0 和 q=0,因为 0&0=0,且 ∣x−p∣+∣y−q∣=∣0−0∣+∣0−0∣=0 是所有 p 和 q 数对中该表达式的最小值。
在第三个测试用例中,一个有效的数对是 p=3 和 q=8,因为 3&8=0,且 ∣x−p∣+∣y−q∣=∣3−3∣+∣8−6∣=2 是所有 p 和 q 数对中该表达式的最小值。注意,(p,q)=(3,4) 也是一个有效的数对。
输入解题思路,AI测评打分。不知道怎么写?