結果

問題 No.939 and or
ユーザー FromBooskaFromBooska
提出日時 2023-09-04 12:34:02
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 884 bytes
コンパイル時間 2,033 ms
コンパイル使用メモリ 86,792 KB
実行使用メモリ 71,580 KB
最終ジャッジ日時 2023-09-04 12:34:09
合計ジャッジ時間 5,875 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
71,224 KB
testcase_01 AC 78 ms
71,180 KB
testcase_02 WA -
testcase_03 AC 78 ms
71,096 KB
testcase_04 AC 76 ms
71,088 KB
testcase_05 AC 76 ms
71,092 KB
testcase_06 WA -
testcase_07 AC 77 ms
71,092 KB
testcase_08 WA -
testcase_09 AC 77 ms
71,136 KB
testcase_10 AC 75 ms
71,260 KB
testcase_11 AC 76 ms
71,376 KB
testcase_12 AC 76 ms
71,452 KB
testcase_13 AC 76 ms
71,248 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 75 ms
71,364 KB
testcase_17 WA -
testcase_18 AC 76 ms
71,548 KB
testcase_19 AC 76 ms
71,092 KB
testcase_20 AC 75 ms
71,268 KB
testcase_21 WA -
testcase_22 AC 78 ms
71,432 KB
testcase_23 AC 78 ms
71,332 KB
testcase_24 AC 76 ms
70,992 KB
testcase_25 AC 76 ms
71,264 KB
testcase_26 AC 75 ms
71,424 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 75 ms
71,176 KB
testcase_30 AC 77 ms
71,052 KB
testcase_31 AC 76 ms
71,332 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# X&Y=Aより、aが1のとき、xもyも1
# X|Y=Bより、bが0のとき、xもyも0
# これによりX, Yの確定桁がわかる、残りの桁はどちらかが1でもう片方が0となる
# X<=Yより、未定桁の最初の数字はx=0, y=1となるしかない、両方が同じ数字には&, |の制約からなりえない
# 残りの未定桁数がdとすれば、パターン数は2**dとなるだろう

A, B = map(int, input().split())
bit_1 = [-1]*30
bit_0 = [-1]*30
undecided = 0
for i in range(30):
    if A>>i&1 == 1:
        bit_1[i] = 1
    if B>>i&1 == 0:
        bit_0[i] = 0
    if bit_1[i] == -1 and bit_0[i] == -1:
        undecided += 1
    if bit_1[i] == 1 and bit_0[i] == 0:
        undecided -= 100
#print(bit_1)
#print(bit_0)
#print(undecided)

if undecided < 0:
    ans = 0
elif undecided == 0:
    ans = 1
else:
    ans = pow(2, undecided-1)
print(ans)
0