結果

問題 No.822 Bitwise AND
ユーザー brthyyjp
提出日時 2022-01-26 17:02:56
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 518 bytes
コンパイル時間 711 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 75,648 KB
最終ジャッジ日時 2024-12-23 08:47:34
合計ジャッジ時間 1,701 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 14 WA * 3
権限があれば一括ダウンロードができます

ソースコード

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