結果
問題 | No.144 エラトステネスのざる |
ユーザー |
|
提出日時 | 2018-07-25 17:19:01 |
言語 | Haskell (9.10.1) |
結果 |
AC
|
実行時間 | 52 ms / 2,000 ms |
コード長 | 609 bytes |
コンパイル時間 | 6,941 ms |
コンパイル使用メモリ | 197,248 KB |
実行使用メモリ | 16,128 KB |
最終ジャッジ日時 | 2024-06-26 11:18:00 |
合計ジャッジ時間 | 8,241 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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.Applicative(<$>)importControl.Monadwhen,foldM,forM_importData.Vector.Unboxed.MutableIOVector,STVectorimportqualifiedData.Vector.Unboxed.MutableasVMmain::IO()main = do[sn, sp] <- words <$> getLinesolve (read sn) (read sp) >>= printsolve::Int->Double->IODoublesolve n p = doev <- VM.replicate (n+1) 1.0 :: IO (IOVector Double)forM_ [2 .. n] $ \i -> doforM_ [2*i, 3*i .. n] $ \j -> dox <- VM.read ev jVM.write ev j (x * (1.0 - p))foldM (\e i -> dox <- VM.read ev ireturn $ e + x) 0.0 [2..n]