結果

問題 No.106 素数が嫌い!2
ユーザー motimoti
提出日時 2018-05-23 01:25:26
言語 Perl
(5.38.2)
結果
AC  
実行時間 1,325 ms / 5,000 ms
コード長 367 bytes
コンパイル時間 109 ms
コンパイル使用メモリ 5,332 KB
実行使用メモリ 69,960 KB
最終ジャッジ日時 2023-09-11 01:29:41
合計ジャッジ時間 8,719 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 635 ms
36,836 KB
testcase_01 AC 5 ms
4,824 KB
testcase_02 AC 5 ms
5,088 KB
testcase_03 AC 5 ms
4,964 KB
testcase_04 AC 631 ms
36,892 KB
testcase_05 AC 1,325 ms
69,708 KB
testcase_06 AC 1,297 ms
69,960 KB
testcase_07 AC 1,306 ms
69,844 KB
testcase_08 AC 63 ms
9,272 KB
testcase_09 AC 5 ms
5,132 KB
testcase_10 AC 5 ms
4,840 KB
testcase_11 AC 548 ms
32,524 KB
testcase_12 AC 1,259 ms
67,908 KB
testcase_13 AC 5 ms
5,092 KB
testcase_14 AC 5 ms
5,096 KB
testcase_15 AC 5 ms
4,960 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.pl syntax OK

ソースコード

diff #

#!/usr/bin/env perl

use strict;
use warnings;

my ($n, $k) = split / /, <>; chomp $k;

if ($k >= 21) {
  print "0\n";
  exit;
}

my $ans = 0;
my @prime_count;
for (my $i = 2; $i <= $n; $i++) {
  if (!$prime_count[$i]) {
    for (my $j = $i; $j <= $n; $j += $i) {
      $prime_count[$j]++;
    }
  }
  if ($prime_count[$i] >= $k) {
    $ans++;
  }
}

print "$ans\n";
0