結果

問題 No.822 Bitwise AND
ユーザー brthyyjpbrthyyjp
提出日時 2022-01-26 17:02:56
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 518 bytes
コンパイル時間 2,109 ms
コンパイル使用メモリ 86,708 KB
実行使用メモリ 77,084 KB
最終ジャッジ日時 2023-08-24 22:23:15
合計ジャッジ時間 3,568 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 85 ms
76,780 KB
testcase_02 AC 116 ms
77,084 KB
testcase_03 AC 70 ms
71,404 KB
testcase_04 AC 81 ms
76,680 KB
testcase_05 AC 70 ms
71,384 KB
testcase_06 AC 81 ms
76,552 KB
testcase_07 AC 81 ms
76,536 KB
testcase_08 AC 72 ms
71,512 KB
testcase_09 AC 72 ms
71,444 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 72 ms
71,548 KB
testcase_13 AC 80 ms
76,444 KB
testcase_14 AC 71 ms
71,232 KB
testcase_15 AC 83 ms
76,660 KB
testcase_16 AC 95 ms
76,680 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, k = map(int, input().split())

if n == 0 and k != 0:
    print('INF')
    exit()

B = []
for i in range(18):
    if (n>>i)&1:
        continue
    else:
        if i <= 10:
            B.append(i)

#print(B)
m = len(B)
ans = 0
import itertools
for p in itertools.product(range(3), repeat=m):
    d = 0
    for j in range(m):
        b = B[j]
        if p[j] == 0:
            continue
        elif p[j] == 1:
            d += 1<<b
        else:
            d -= 1<<b
    if 0 <= d <= k:
        ans += 1
print(ans)
0