結果

問題 No.822 Bitwise AND
ユーザー brthyyjpbrthyyjp
提出日時 2022-01-26 17:07:16
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 506 bytes
コンパイル時間 277 ms
コンパイル使用メモリ 87,024 KB
実行使用メモリ 76,940 KB
最終ジャッジ日時 2023-08-24 22:33:25
合計ジャッジ時間 2,619 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 84 ms
76,500 KB
testcase_02 AC 117 ms
76,812 KB
testcase_03 AC 71 ms
70,956 KB
testcase_04 AC 83 ms
76,496 KB
testcase_05 AC 71 ms
71,068 KB
testcase_06 AC 82 ms
76,532 KB
testcase_07 AC 83 ms
76,476 KB
testcase_08 AC 72 ms
71,504 KB
testcase_09 AC 71 ms
71,508 KB
testcase_10 AC 73 ms
71,212 KB
testcase_11 AC 73 ms
71,292 KB
testcase_12 AC 74 ms
71,276 KB
testcase_13 AC 84 ms
76,652 KB
testcase_14 AC 72 ms
71,200 KB
testcase_15 AC 82 ms
76,476 KB
testcase_16 AC 97 ms
76,592 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

if n < k:
    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