結果

問題 No.713 素数の和
ユーザー ikd
提出日時 2018-07-16 02:32:35
言語 Nim
(2.2.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 336 bytes
コンパイル時間 3,166 ms
コンパイル使用メモリ 65,444 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-01 03:12:17
合計ジャッジ時間 3,700 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

import strutils, sequtils

var n=stdin.readLine.parseInt

proc isPrime(x: int): bool=
  if x==1:
    return false
  elif x==2:
    return true
  else:
    for i in 2..x:
      if i*i>x:
        break
      if x mod i==0:
        return false
    return true

var ps=filter(toSeq(1..n)) do(x: int)->bool: isPrime(x)
echo ps.foldl(a+b, 0)
0