結果

問題 No.713 素数の和
コンテスト
ユーザー 情報学生
提出日時 2019-08-25 14:11:18
言語 Haskell
(9.14.1)
コンパイル:
ghc -rtsopts -with-rtsopts=-K1G -o a.out -O2 _filename_
実行:
./a.out
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 389 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 9,326 ms
コンパイル使用メモリ 194,684 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-05-06 18:33:51
合計ジャッジ時間 11,369 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 6
権限があれば一括ダウンロードができます
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.14.1/environments/default
[1 of 2] Compiling Main             ( Main.hs, Main.o )
[2 of 2] Linking a.out

ソースコード

diff #
raw source code

primes :: Integral a => [a]
primes = map fromIntegral $ [2, 3] ++ primes'
    where
        primes'        = [5] ++ f 1 7 primes'
        f m s (p : ps) = [n | n <- ns, gcd m n == 1] ++ f (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
    print $ sum $ filter (<= n) $ take 1000 primes
0