結果

問題 No.822 Bitwise AND
ユーザー nebukuro09
提出日時 2019-04-26 21:45:40
言語 D
(dmd 2.109.1)
結果
AC  
実行時間 94 ms / 2,000 ms
コード長 525 bytes
コンパイル時間 871 ms
コンパイル使用メモリ 114,288 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-22 00:58:18
合計ジャッジ時間 1,914 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop;

void main() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto K = s[1];

    if (N < K) {
        writeln("INF");
        return;
    }

    int ans = 0;

    foreach (i; 0..(1<<18)) {
        foreach (j; i..i+K+1) {
            if ((i & j) == N) {
                ans += 1;
            }
        }
    }

    ans.writeln;
}
0