結果

問題 No.1298 OR XOR
ユーザー ayaoniayaoni
提出日時 2020-11-27 21:27:34
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 74 ms / 2,000 ms
コード長 1,257 bytes
コンパイル時間 2,128 ms
コンパイル使用メモリ 86,416 KB
実行使用メモリ 71,304 KB
最終ジャッジ日時 2023-10-01 04:40:58
合計ジャッジ時間 2,325 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,220 KB
testcase_01 AC 70 ms
71,280 KB
testcase_02 AC 73 ms
71,304 KB
testcase_03 AC 72 ms
71,104 KB
testcase_04 AC 71 ms
71,212 KB
testcase_05 AC 71 ms
71,212 KB
testcase_06 AC 72 ms
71,152 KB
testcase_07 AC 74 ms
71,300 KB
testcase_08 AC 72 ms
70,992 KB
testcase_09 AC 72 ms
71,248 KB
testcase_10 AC 73 ms
71,172 KB
testcase_11 AC 73 ms
71,112 KB
testcase_12 AC 73 ms
70,980 KB
testcase_13 AC 73 ms
71,176 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def LS2(): return list(sys.stdin.readline().rstrip())


N = I()


def popcount(n):
    c = (n & 0x5555555555555555) + ((n >> 1) & 0x5555555555555555)
    c = (c & 0x3333333333333333) + ((c >> 2) & 0x3333333333333333)
    c = (c & 0x0f0f0f0f0f0f0f0f) + ((c >> 4) & 0x0f0f0f0f0f0f0f0f)
    c = (c & 0x00ff00ff00ff00ff) + ((c >> 8) & 0x00ff00ff00ff00ff)
    c = (c & 0x0000ffff0000ffff) + ((c >> 16) & 0x0000ffff0000ffff)
    c = (c & 0x00000000ffffffff) + ((c >> 32) & 0x00000000ffffffff)
    return c


X = popcount(N)
if X == 1:
    print(-1,-1,-1)
else:
    l = N.bit_length()
    a = 0
    A,B,C = 0,0,0
    for i in range(l):
        if (N>>i) & 1:
            if a != 1:
                A += 1<<i
                B += 1<<i
                a += 1
            else:
                A += 1<<i
                C += 1<<i
                a += 1
    print(A,B,C)

0