No.1298 OR XOR
Problem Statement
You are given a positive integer $N$.
- $A\ \mathrm{or}\ B = B\ \mathrm{or}\ C = C\ \mathrm{or}\ A = N$
- $A\ \mathrm{xor}\ B\ \mathrm{xor}\ C = 0$
Find one triple of positive integers $(A, B, C)$ satisfying both of the above conditions, if such a triple exists.
In this statement, $\mathrm{or}$ denotes bitwise OR and $\mathrm{xor}$ denotes bitwise exclusive OR.
Constraints
- $N$ is an integer.
- $1 \le N\le 2^{30}$
Input
The input is given from standard input in the following format.$N$
Output
If a triple $(A, B, C)$ satisfying the conditions exists, output it as follows.
$A\ B\ C$If no triple $(A, B, C)$ satisfying the conditions exists, output the following.
$-1\ -1\ -1$
Sample
Sample 1
Input
3
Output
1 2 3
In this case, $A = 1, B= 2, C = 3$.
- $A$ or $B = B$ or $C = C$ or $ A = 3$
- $A$ xor $B$ xor $C = 0$
These are indeed satisfied.
Outputs such as $2\ 1\ 3$ or $3\ 1\ 2$ are also accepted, but note that the output $3\ 3\ 0$ is judged incorrect because it violates the constraint that $(A, B, C)$ are all positive integers.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
nok0
Kite_kuma