結果

問題 No.1298 OR XOR
ユーザー RustyRusty
提出日時 2023-01-17 16:22:50
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 70 ms / 2,000 ms
コード長 504 bytes
コンパイル時間 282 ms
コンパイル使用メモリ 87,096 KB
実行使用メモリ 71,716 KB
最終ジャッジ日時 2023-08-30 20:15:20
合計ジャッジ時間 2,243 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,448 KB
testcase_01 AC 69 ms
71,536 KB
testcase_02 AC 68 ms
71,272 KB
testcase_03 AC 69 ms
71,404 KB
testcase_04 AC 69 ms
71,716 KB
testcase_05 AC 69 ms
71,396 KB
testcase_06 AC 68 ms
71,272 KB
testcase_07 AC 70 ms
71,456 KB
testcase_08 AC 70 ms
71,392 KB
testcase_09 AC 69 ms
71,152 KB
testcase_10 AC 69 ms
71,248 KB
testcase_11 AC 69 ms
71,380 KB
testcase_12 AC 69 ms
71,392 KB
testcase_13 AC 68 ms
71,268 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
L = [int(s) for s in list(bin(n)[2:])]
a,b,c = 0,0,0
if sum(L) < 2:
    a,b,c = -1,-1,-1
    print(a,b,c)
else:
    t = 2
    for i in range(-1,-len(L)-1,-1):
        if L[i] > 0 and t == 2:
            t -= 1
            a += 1 << (-1-i)
            b += 1 << (-1-i)
        elif L[i] > 0 and t == 1:
            t -= 1
            a += 1 << (-1-i)
            c += 1 << (-1-i)
        elif L[i] > 0 and t == 0:
            a += 1 << (-1-i)
            b += 1 << (-1-i)
    print(a,b,c)
0