結果
問題 | No.713 素数の和 |
ユーザー | はむ吉🐹 |
提出日時 | 2018-07-13 22:28:53 |
言語 | Haskell (9.6.2) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 559 bytes |
コンパイル時間 | 4,748 ms |
コンパイル使用メモリ | 158,844 KB |
実行使用メモリ | 7,284 KB |
最終ジャッジ日時 | 2023-07-30 09:45:46 |
合計ジャッジ時間 | 4,718 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge11 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 3 ms
7,168 KB |
testcase_01 | AC | 2 ms
7,160 KB |
testcase_02 | AC | 3 ms
7,160 KB |
testcase_03 | AC | 3 ms
7,232 KB |
testcase_04 | AC | 3 ms
7,284 KB |
testcase_05 | AC | 2 ms
7,180 KB |
testcase_06 | AC | 2 ms
7,068 KB |
testcase_07 | AC | 3 ms
7,212 KB |
testcase_08 | AC | 3 ms
7,232 KB |
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.6.1/environments/default [1 of 2] Compiling Main ( Main.hs, Main.o ) [2 of 2] Linking a.out
ソースコード
import Data.Int (Int64) -- | Generates the sequence of prime numbers by another method. -- Based on <http://qiita.com/little_Haskeller/items/614a3ae20a517c19bb1f this article> . primes2 :: [Int64] primes2 = map fromIntegral primes2' where primes2' = [2, 3, 5] ++ sieve2 5 7 (drop 2 primes2') sieve2 m s (p : ps) = [n | n <- ns, gcd m n == 1] ++ sieve2 (m * p) (p * p) ps where ns = [x + y | x <- [s, s + 6 .. p * p - 2], y <- [0, 4]] main :: IO () main = do n <- readLn :: IO Int64 print $ sum $ takeWhile (<= n) primes2