結果

問題 No.581 XOR
ユーザー toshiro_yanagi
提出日時 2021-07-01 05:41:44
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 31 ms / 2,000 ms
コード長 401 bytes
コンパイル時間 120 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-06-27 15:13:50
合計ジャッジ時間 1,059 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

def trfm(x):
    r = []
    while x > 0:
        r += [x % 2]
        x = x // 2
    return r


a, c = map(int, input().split())

ta = trfm(a)
tc = trfm(c)
while len(ta) != len(tc):
    if len(ta) < len(tc):
        ta.append(0)
    else:
        tc.append(0)

tb = []
for i in range(len(tc)):
    tb.append(abs(tc[i] - ta[i]))

ans = 0
for i in range(len(tb)):
    ans += tb[i] * (2 ** i)
print(ans)
0