結果

問題 No.939 and or
ユーザー FromBooskaFromBooska
提出日時 2023-04-22 08:35:00
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,030 bytes
コンパイル時間 153 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 52,864 KB
最終ジャッジ日時 2024-04-24 14:36:08
合計ジャッジ時間 2,392 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

# 二進数なので二進数桁ごとに見る
# X&Y = Aということは、Aバイナリが1のところはXもYも1
# X|Y = Bということは、Bバイナリが0のところはXもYも0
# あるバイナリ桁でA=1, B=0のときは矛盾で答えは0となる
# あるバイナリ桁でA=0, B=1のときは2通りあるが、X<=Yの制約がある
# A=1, B=1であればXもYも1
# A=0, B=0であればXもYも0
# X<=Yの制約があるので最初のチョイスのときだけYに1を割り振ればいいか

A, B = map(int, input().split())
A_digit = len(bin(A))-2
B_digit = len(bin(B))-2

ans = 1
for d in range(32):
    a = (A>>d & 1)
    b = (B>>d & 1)
    print('d', d, 'a', a, 'b', b)
    if (a, b) == (1, 1):
        ans *= 1
    elif (a, b) == (1, 0):
        ans = 0
    elif (a, b) == (0, 1):
        ans *= 2
    elif (a, b) == (0, 0):
        ans *= 1

# X<=Yの制約があるので最初のチョイスのときだけYに1を割り振ればいいか
if ans >= 2:
    print(ans//2)
else:
    print(ans)




0