CF round #804 Div.2 A

A. The Third Three Number Problem

time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

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

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

Input

Each test contains multiple test cases. The first line contains a single integer tt (1≤t≤1041≤t≤104) — 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≤n≤109).

Output

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

Example

input

Copy

5
4
1
12
2046
194723326

output

Copy

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

Note

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⊕3)+(3⊕1)+(3⊕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⊕4)+(4⊕6)+(2⊕6)=6+2+4=12.

#include<bits/stdc++.h>
using namespace std;
void solve(){
    int n;
    scanf("%d",&n);
    if(n&1)printf("-1\n");
    else{
        printf("0 0 %d\n",n/2);
    }
}
int main(){
    int t=1;
    scanf("%d",&t);
    for(int i = 1;i<=t;i++){
        solve();
    }
    return 0;
}
/*
p*t = a^2+b^2
q*t = ab
(p+2*q)*t=(a+b)^2
*/

赛后补题

(太nb了!

补题的时候第一遍交的是

#include<bits/stdc++.h>
using namespace std;
void solve(){
    int n;
    scanf("%d",&n);
    if(n==1)printf("-1\n");
    else{....

没过,

还是不明白这里的“n==1”和“n&1”有什么区别捏

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值