結果

問題 No.106 素数が嫌い!2
ユーザー kokatsukokatsu
提出日時 2022-01-13 22:36:07
言語 D
(dmd 2.107.1)
結果
AC  
実行時間 354 ms / 5,000 ms
コード長 582 bytes
コンパイル時間 1,744 ms
コンパイル使用メモリ 201,616 KB
実行使用メモリ 20,716 KB
最終ジャッジ日時 2023-09-04 15:41:41
合計ジャッジ時間 5,236 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 163 ms
11,736 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 164 ms
11,272 KB
testcase_05 AC 353 ms
19,940 KB
testcase_06 AC 354 ms
20,716 KB
testcase_07 AC 351 ms
20,212 KB
testcase_08 AC 22 ms
4,376 KB
testcase_09 AC 23 ms
4,380 KB
testcase_10 AC 348 ms
19,960 KB
testcase_11 AC 142 ms
10,264 KB
testcase_12 AC 341 ms
18,656 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 1 ms
4,384 KB
testcase_15 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std;

void main() {
    long N, K;
    readf("%d %d\n", N, K);

    auto lpf = iota(N+1).array;
    foreach (i; 2 .. N+1) {
        if (lpf[i] != i) continue;

        foreach (j; iota(i*i, N+1, i)) {
            if (lpf[j] != j) continue;

            lpf[j] = i;
        }
    }

    long res;
    foreach (i; 2 .. N+1) {
        long num = i, cnt;
        while (num > 1) {
            ++cnt;

            long p = lpf[num];
            while (num % p == 0) {
                num /= lpf[num];
            }
        }

        if (cnt >= K) ++res;
    }

    res.writeln;
}
0