結果

問題 No.106 素数が嫌い!2
ユーザー te-shte-sh
提出日時 2016-08-30 16:44:41
言語 D
(dmd 2.106.1)
結果
AC  
実行時間 83 ms / 5,000 ms
コード長 533 bytes
コンパイル時間 685 ms
コンパイル使用メモリ 103,868 KB
実行使用メモリ 19,600 KB
最終ジャッジ日時 2023-09-02 21:36:46
合計ジャッジ時間 1,936 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
13,056 KB
testcase_01 AC 2 ms
4,368 KB
testcase_02 AC 1 ms
4,372 KB
testcase_03 AC 1 ms
4,372 KB
testcase_04 AC 45 ms
12,392 KB
testcase_05 AC 42 ms
10,976 KB
testcase_06 AC 38 ms
11,024 KB
testcase_07 AC 38 ms
11,020 KB
testcase_08 AC 7 ms
4,376 KB
testcase_09 AC 4 ms
4,368 KB
testcase_10 AC 39 ms
11,800 KB
testcase_11 AC 17 ms
6,188 KB
testcase_12 AC 83 ms
19,600 KB
testcase_13 AC 1 ms
4,372 KB
testcase_14 AC 1 ms
4,372 KB
testcase_15 AC 1 ms
4,368 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

void main()
{
  auto rd = readln.split.map!(to!int);
  auto n = rd[0], k = rd[1];

  auto pfi = primeFactors(n);
  
  writeln(pfi.filter!(pf => pf >= k).array.length);
}

int[] primeFactors(int n)
{
  auto sieve = new int[n + 1];

  foreach (p; 2..n + 1)
    if (sieve[p] == 0)
      foreach (q; iota(p, n + 1, p))
        sieve[q] += 1;

  return sieve;
}
0