結果
| 問題 | 
                            No.106 素数が嫌い!2
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2019-01-19 21:58:46 | 
| 言語 | Nim  (2.2.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 724 bytes | 
| コンパイル時間 | 2,560 ms | 
| コンパイル使用メモリ | 61,744 KB | 
| 実行使用メモリ | 20,684 KB | 
| 最終ジャッジ日時 | 2024-07-01 10:23:48 | 
| 合計ジャッジ時間 | 4,014 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 9 WA * 4 | 
ソースコード
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