結果

問題 No.106 素数が嫌い!2
ユーザー むらためむらため
提出日時 2019-01-19 21:58:46
言語 Nim
(2.0.2)
結果
WA  
実行時間 -
コード長 724 bytes
コンパイル時間 2,795 ms
コンパイル使用メモリ 69,212 KB
実行使用メモリ 36,280 KB
最終ジャッジ日時 2023-09-14 02:20:42
合計ジャッジ時間 4,895 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
36,132 KB
testcase_01 AC 75 ms
36,236 KB
testcase_02 AC 80 ms
36,208 KB
testcase_03 AC 67 ms
36,132 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 73 ms
36,280 KB
testcase_07 AC 76 ms
36,164 KB
testcase_08 WA -
testcase_09 AC 75 ms
35,992 KB
testcase_10 AC 79 ms
36,176 KB
testcase_11 AC 75 ms
36,268 KB
testcase_12 WA -
testcase_13 AC 70 ms
36,080 KB
testcase_14 AC 69 ms
36,280 KB
testcase_15 AC 67 ms
36,076 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sequtils,math
proc getchar_unlocked():char {. importc:"getchar_unlocked",header: "<stdio.h>" .}
proc scan(): int =
  while true:
    var k = getchar_unlocked()
    if k < '0': break
    result = 10 * result + k.ord - '0'.ord

proc getTotals(n:int) :seq[int] = # [0...n] O(n loglog n)
  var isPrimes = newSeqWith(n+1,true)
  var totals = newSeqWith(n+1,0)
  for i in 2..n.float.sqrt.int :
    if not isPrimes[i]: continue
    totals[i] += 1
    for j in countup(i*2,n,i):
      isPrimes[j] = false
      totals[j] += 1
  for i in 2..n:
    if totals[i] == 0 : totals[i] = 1
  return totals
let totals = getTotals(200_0010)
let n = scan()
let k = scan()
var ans = 0
for i in 2..n:
  if totals[i] >= k: ans += 1
echo ans
0