結果

問題 No.144 エラトステネスのざる
ユーザー はむ吉🐹
提出日時 2015-10-28 22:19:20
言語 Haskell
(9.10.1)
結果
TLE  
実行時間 -
コード長 326 bytes
コンパイル時間 5,529 ms
コンパイル使用メモリ 176,256 KB
実行使用メモリ 10,656 KB
最終ジャッジ日時 2024-09-13 04:17:56
合計ジャッジ時間 9,239 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 10 TLE * 1 -- * 6
権限があれば一括ダウンロードができます
コンパイルメッセージ
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

ソースコード

diff #

import Control.Applicative ((<$>))

countFactors :: Int -> Int
countFactors n = length [f | f <- [1 .. n], mod n f == 0]

prob :: Double -> Int -> Double
prob p n = (1 - p) ** (fromIntegral $ countFactors n - 2)

main :: IO ()
main = do
    (n : p : _) <- words <$> getLine
    print $ sum $ map (prob $ read p) [2 .. read n]
0