CF2187B.Shortest Statement Ever

普及+/提高

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

You are given two non-negative integers xx, yy. Find two non-negative integers pp and qq such that p  &  q=0p\;\&\;q=0, and ∣x−p∣+∣y−q∣|x-p|+|y-q| is minimized. Here, &\& denotes the bitwise AND operation.

给你两个非负整数 xx、yy。请找出两个非负整数 pp 和 qq,使得 p  &  q=0p\;\&\;q=0,且 ∣x−p∣+∣y−q∣|x-p|+|y-q| 最小。其中,&\& 表示按位与运算。

输入格式

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 only line of each test case contains two non-negative integers xx and yy (0≤x,y<2300 \le x,y \lt 2^{30}).

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

每个测试用例仅有一行,包含两个非负整数 xx 和 yy(0≤x,y<2300 \le x,y \lt 2^{30})。

输出格式

For each test case, output two non-negative integers pp and qq you found. If there are multiple pairs of pp and qq 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\max(p,q) \lt 2^{31}.

对于每个测试用例,输出你找到的两个非负整数 pp 和 qq。如果存在多组满足条件的 pp 和 qq,你可以输出其中任意一组。

可以证明,在本题的约束条件下,任何合法解均满足 max⁡(p,q)<231\max(p,q) \lt 2^{31}。

输入输出样例

  • 输入#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=0p=0 and q=0q=0, as 0 & 0=00\,\&\,0=0 and ∣x−p∣+∣y−q∣=∣0−0∣+∣0−0∣=0|x-p|+|y-q|=|0-0|+|0-0|=0 is the minimum over all pairs of pp and qq.

In the third test case, one valid pair would be p=3p=3 and q=8q=8, as 3 & 8=03\,\&\,8=0 and ∣x−p∣+∣y−q∣=∣3−3∣+∣8−6∣=2|x-p|+|y-q|=|3-3|+|8-6|=2 is the minimum over all pairs of pp and qq. Note that (p,q)=(3,4)(p,q)=(3,4) is also a valid pair.

在第一个测试用例中,一个有效的数对是 p=0p=0 和 q=0q=0,因为 0 & 0=00\,\&\,0=0,且 ∣x−p∣+∣y−q∣=∣0−0∣+∣0−0∣=0|x-p|+|y-q|=|0-0|+|0-0|=0 是所有 pp 和 qq 数对中该表达式的最小值。

在第三个测试用例中,一个有效的数对是 p=3p=3 和 q=8q=8,因为 3 & 8=03\,\&\,8=0,且 ∣x−p∣+∣y−q∣=∣3−3∣+∣8−6∣=2|x-p|+|y-q|=|3-3|+|8-6|=2 是所有 pp 和 qq 数对中该表达式的最小值。注意,(p,q)=(3,4)(p,q)=(3,4) 也是一个有效的数对。

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

首页