結果

問題 No.822 Bitwise AND
ユーザー MisterMister
提出日時 2020-08-01 22:23:52
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 59 ms / 2,000 ms
コード長 447 bytes
コンパイル時間 637 ms
コンパイル使用メモリ 68,148 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-08 01:16:56
合計ジャッジ時間 1,851 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,384 KB
testcase_03 AC 1 ms
4,384 KB
testcase_04 AC 59 ms
4,384 KB
testcase_05 AC 25 ms
4,384 KB
testcase_06 AC 41 ms
4,380 KB
testcase_07 AC 59 ms
4,384 KB
testcase_08 AC 2 ms
4,384 KB
testcase_09 AC 2 ms
4,384 KB
testcase_10 AC 2 ms
4,384 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 3 ms
4,384 KB
testcase_13 AC 1 ms
4,384 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 32 ms
4,384 KB
testcase_16 AC 1 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>

void solve() {
    int n, k;
    std::cin >> n >> k;

    if (n + 1 <= k) {
        std::cout << "INF\n";
        return;
    }

    int ans = 0;
    for (int x = 0; x <= n * 2; ++x) {
        for (int d = 0; d <= k; ++d) {
            if ((x & (x + d)) == n) ++ans;
        }
    }

    std::cout << ans << "\n";
}

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    solve();

    return 0;
}
0