結果

問題 No.1298 OR XOR
ユーザー knk_keiknk_kei
提出日時 2021-02-03 01:10:57
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 921 bytes
コンパイル時間 94 ms
コンパイル使用メモリ 10,544 KB
実行使用メモリ 7,988 KB
最終ジャッジ日時 2023-09-12 11:32:50
合計ジャッジ時間 3,162 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,924 KB
testcase_01 WA -
testcase_02 AC 15 ms
7,896 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 15 ms
7,924 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
"""
A,B,C のそれぞれの桁ごとのor がNになる。
A xor B xor C = 0だからbitごとの1の数が 0 or 2。
となるa,b,cが存在するか、また出力
bitごとに考えて、A or B,B or C ,CorAが同じになる。
0になるならa,b,c全て0 でxor条件を満たす
1になるなら1は2or3必要で 条件を満たすために 1の数は2
構築としては、A=B=Nとして作ってよくてCだけNのbitが1の時減らす
ただし、c = 0ならダメなので、n の最初に出てくる1のbitを変える。
c が0になるケースは1のbitが複数あればOK
nの1のbitが1つならNG
"""
b = n
c = n
flag_one = 0
for i in range(31):
    if n >> i and 1:
        if flag_one == 0:
            b -= pow(2, i)
            flag_one = 1
        else:
            c -= pow(2, i)
            flag_one = 2
if flag_one == 1:
    print(-1, -1, -1)
else:
    print(n, b, c)
0