問題一覧 > 通常問題

No.1298 OR XOR

レベル : / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / スペシャルジャッジ問題 (複数の解が存在する可能性があります)
タグ : (AC するまで非表示) / 解いたユーザー数 406
作問者 : nok0 / テスター : zkou Kite_kuma
お気に入りにしたユーザー ProblemId : 5382 / 自分の提出
問題文最終更新日: 2020-11-15 13:10:03
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 276 (順位表) の他の問題:

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.

Wikipedia: Logical disjunction

Wikipedia: 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もしくは右上の雲マークをクリックしてアカウントを作成してください。