結果

問題 No.822 Bitwise AND
ユーザー gew1fw
提出日時 2025-06-12 20:46:55
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 467 bytes
コンパイル時間 248 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 59,904 KB
最終ジャッジ日時 2025-06-12 20:47:22
合計ジャッジ時間 1,839 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 14 WA * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

N, K = map(int, input().split())

if N == 0:
    if K == 0:
        print(1)
    else:
        print("INF")
else:
    count = 0
    max_x = N + 2 * K  # Covering x up to N + 2K to handle all possible y = x + K
    for x in range(N, max_x + 1):
        if (x & N) != N:
            continue  # x must have all bits of N set
        max_y = min(x + K, max_x)
        for y in range(x, max_y + 1):
            if (x & y) == N:
                count += 1
    print(count)
0