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”有什么区别捏