結果

問題 No.144 エラトステネスのざる
ユーザー はむ吉🐹はむ吉🐹
提出日時 2015-10-28 22:19:20
言語 Haskell
(9.8.2)
結果
TLE  
実行時間 -
コード長 326 bytes
コンパイル時間 824 ms
コンパイル使用メモリ 161,792 KB
実行使用メモリ 10,188 KB
最終ジャッジ日時 2023-10-11 04:59:49
合計ジャッジ時間 5,060 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
7,536 KB
testcase_01 AC 2 ms
7,468 KB
testcase_02 AC 3 ms
7,724 KB
testcase_03 AC 3 ms
7,452 KB
testcase_04 AC 2 ms
7,596 KB
testcase_05 AC 3 ms
7,500 KB
testcase_06 AC 12 ms
7,468 KB
testcase_07 AC 12 ms
7,760 KB
testcase_08 AC 12 ms
7,640 KB
testcase_09 AC 12 ms
7,536 KB
testcase_10 AC 12 ms
7,636 KB
testcase_11 AC 12 ms
7,820 KB
testcase_12 AC 12 ms
7,736 KB
testcase_13 TLE -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.6.1/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