結果

問題 No.822 Bitwise AND
コンテスト
ユーザー gew1fw
提出日時 2025-06-12 15:52:31
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
WA  
実行時間 -
コード長 467 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 243 ms
コンパイル使用メモリ 95,980 KB
実行使用メモリ 83,456 KB
最終ジャッジ日時 2026-07-11 15:20:12
合計ジャッジ時間 2,692 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 14 WA * 3
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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