CF1699A.The Third Three Number Problem

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

You are given a positive integer nn. Your task is to find any three integers aa, bb and cc (0≤a,b,c≤1090 \le a, b, c \le 10^9) for which (a⊕b)+(b⊕c)+(a⊕c)=n(a\oplus b)+(b\oplus c)+(a\oplus c)=n, or determine that there are no such integers.

Here a⊕ba \oplus b denotes the bitwise XOR of aa and bb. For example, 2⊕4=62 \oplus 4 = 6 and 3⊕1=23 \oplus 1=2.

给你一个正整数 nn。你的任务是找出任意三个整数 aa、bb 和 cc(满足 0≤a,b,c≤1090 \le a, b, c \le 10^9),使得 (a⊕b)+(b⊕c)+(a⊕c)=n(a\oplus b)+(b\oplus c)+(a\oplus c)=n;如果不存在这样的整数,则判定其不存在。

其中,a⊕ba \oplus b 表示 aa 与 bb 的按位异或运算。例如,2⊕4=62 \oplus 4 = 6,而 3⊕1=23 \oplus 1 = 2。

输入格式

Each test contains multiple test cases. The first line contains a single integer tt (1≤t≤1041 \le t \le 10^4) — the number of test cases. The following lines contain the descriptions of the test cases.

The only line of each test case contains a single integer nn (1≤n≤1091 \le n \le 10^9).

每个测试包含多个测试用例。第一行包含一个整数 tt(1≤t≤1041 \le t \le 10^4),表示测试用例的数量。接下来的行描述各测试用例。

每个测试用例仅有一行,包含一个整数 nn(1≤n≤1091 \le n \le 10^9)。

输出格式

For each test case, print any three integers aa, bb and cc (0≤a,b,c≤1090 \le a, b, c \le 10^9) for which (a⊕b)+(b⊕c)+(a⊕c)=n(a\oplus b)+(b\oplus c)+(a\oplus c)=n. If no such integers exist, print −1-1.

对于每个测试用例,输出任意三个整数 aa、bb 和 cc(满足 0≤a,b,c≤1090 \le a, b, c \le 10^9),使得 (a⊕b)+(b⊕c)+(a⊕c)=n(a\oplus b)+(b\oplus c)+(a\oplus c)=n。若不存在这样的整数,则输出 −1-1。

输入输出样例

  • 输入#1

    5
    4
    1
    12
    2046
    194723326

    输出#1

    3 3 1
    -1
    2 4 6
    69 420 666
    12345678 87654321 100000000

说明/提示

In the first test case, a=3a=3, b=3b=3, c=1c=1, so (3⊕3)+(3⊕1)+(3⊕1)=0+2+2=4(3 \oplus 3)+(3 \oplus 1) + (3 \oplus 1)=0+2+2=4.

In the second test case, there are no solutions.

In the third test case, (2⊕4)+(4⊕6)+(2⊕6)=6+2+4=12(2 \oplus 4)+(4 \oplus 6) + (2 \oplus 6)=6+2+4=12.

在第一个测试用例中,a=3a=3,b=3b=3,c=1c=1,因此 (3⊕3)+(3⊕1)+(3⊕1)=0+2+2=4(3 \oplus 3)+(3 \oplus 1) + (3 \oplus 1)=0+2+2=4。

在第二个测试用例中,无解。

在第三个测试用例中,(2⊕4)+(4⊕6)+(2⊕6)=6+2+4=12(2 \oplus 4)+(4 \oplus 6) + (2 \oplus 6)=6+2+4=12。

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

首页