A15244 | The Third Three Number Problem
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
You are given a positive integer $n$ . Your task is to find any three integers $a$ , $b$ and $c$ ( $0 \le a, b, c \le 10^9$ ) for which $(a\oplus b)+(b\oplus c)+(a\oplus c)=n$ , or determine that there are no such integers.
Here $a \oplus b$ denotes the [bitwise XOR](https://en.wikipedia.org/wiki/Bitwise_operation#XOR) of $a$ and $b$ . For example, $2 \oplus 4 = 6$ and $3 \oplus 1=2$ .
Here $a \oplus b$ denotes the [bitwise XOR](https://en.wikipedia.org/wiki/Bitwise_operation#XOR) of $a$ and $b$ . For example, $2 \oplus 4 = 6$ and $3 \oplus 1=2$ .
输入格式
Each test contains multiple test cases. The first line contains a single integer $t$ ( $1 \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 $n$ ( $1 \le n \le 10^9$ ).
The only line of each test case contains a single integer $n$ ( $1 \le n \le 10^9$ ).
输出格式
For each test case, print any three integers $a$ , $b$ and $c$ ( $0 \le a, b, c \le 10^9$ ) for which $(a\oplus b)+(b\oplus c)+(a\oplus c)=n$ . If no such integers exist, print $-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=3$ , $b=3$ , $c=1$ , so $(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 \oplus 4)+(4 \oplus 6) + (2 \oplus 6)=6+2+4=12$ .
In the second test case, there are no solutions.
In the third test case, $(2 \oplus 4)+(4 \oplus 6) + (2 \oplus 6)=6+2+4=12$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted