結果
問題 | No.144 エラトステネスのざる |
ユーザー |
|
提出日時 | 2015-02-07 11:36:49 |
言語 | Haskell (9.10.1) |
結果 |
AC
|
実行時間 | 110 ms / 2,000 ms |
コード長 | 733 bytes |
コンパイル時間 | 4,324 ms |
コンパイル使用メモリ | 177,024 KB |
実行使用メモリ | 28,288 KB |
最終ジャッジ日時 | 2024-12-30 03:17:21 |
合計ジャッジ時間 | 6,258 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.8.2/environments/default [1 of 2] Compiling Main ( Main.hs, Main.o ) [2 of 2] Linking a.out
ソースコード
importControl.MonadimportControl.Monad.STimportData.Array.STimportData.Array.UnboxedimportData.FunctorimportDebug.Traceprimes::Int->Double->UArrayIntDoubleprimes n p = runSTUArray (newArray (2, n) 1.0 >>= sieve 2)whereinvp = 1 - psup = nsieve i arr| i > sup = return arr| otherwise = erase (i * 2) >>= sieve (i + 1)whereerase j| j > sup = return arr| otherwise =readArray arr j >>= \ b ->writeArray arr j (invp * b) >>erase (j + i)main =words <$> getLine >>= \ (f0:f1:_) ->let n = read f0 :: Intp = read f1 :: Doublein (putStrLn . show) (foldr (+) 0 (elems (primes n p)))