結果

問題 No.106 素数が嫌い!2
ユーザー te-shte-sh
提出日時 2016-08-30 16:42:35
言語 D
(dmd 2.106.1)
結果
WA  
実行時間 -
コード長 581 bytes
コンパイル時間 1,542 ms
コンパイル使用メモリ 153,556 KB
実行使用メモリ 19,136 KB
最終ジャッジ日時 2023-09-02 21:36:38
合計ジャッジ時間 5,140 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
権限があれば一括ダウンロードができます

ソースコード

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];

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

  writeln(sieve);
  return sieve;
}
0