結果

問題 No.822 Bitwise AND
ユーザー xuzijian629
提出日時 2019-04-26 21:45:15
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 60 ms / 2,000 ms
コード長 494 bytes
コンパイル時間 2,016 ms
コンパイル使用メモリ 191,880 KB
最終ジャッジ日時 2025-01-07 03:07:45
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    if (k == 0) {
        cout << 1 << endl;
        return 0;
    }
    if (n < k) {
        cout << "INF" << endl;
        return 0;
    }
    int cnt = 0;
    for (int i = 0; i <= n << 1; i++) {
        for (int j = i; j <= i + k; j++) {
            if ((i & j) == n) {
                cnt++;
            }
        }
    }
    cout << cnt << endl;
}
0