結果
問題 | No.144 エラトステネスのざる |
ユーザー |
![]() |
提出日時 | 2016-04-17 16:06:27 |
言語 | Haskell (9.10.1) |
結果 |
AC
|
実行時間 | 99 ms / 2,000 ms |
コード長 | 745 bytes |
コンパイル時間 | 2,741 ms |
コンパイル使用メモリ | 174,848 KB |
実行使用メモリ | 12,160 KB |
最終ジャッジ日時 | 2024-10-04 10:25:39 |
合計ジャッジ時間 | 3,428 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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.ApplicativeimportControl.MonadimportData.Array.STimportData.Array.UnboxedimportText.Printf-- Reference: http://sucrose.hatenablog.com/entry/2014/10/10/235805numDivisorsTable::Int->UArrayIntIntnumDivisorsTable n = runSTUArray $ dot <- newArray (1, n) 0forM_ [1 .. n] $ \i -> doforM_ [i, 2 * i .. n] $ \j -> dowriteArray t j . (+ 1) =<< readArray t jreturn tcomputeProbability::Double->Int->DoublecomputeProbability p n = sum $ map prob [2 .. n]wheret = numDivisorsTable nprob i = (1 - p) ** (fromIntegral $ subtract 2 $ t ! i)main::IO()main = do[n, p] <- words <$> getLineprintf "%.12f\n" $ computeProbability (read p) (read n)