結果
| 問題 | No.144 エラトステネスのざる |
| コンテスト | |
| ユーザー |
okaduki
|
| 提出日時 | 2015-02-06 01:10:28 |
| 言語 | Haskell (9.10.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 678 bytes |
| 記録 | |
| コンパイル時間 | 1,617 ms |
| コンパイル使用メモリ | 174,592 KB |
| 実行使用メモリ | 21,120 KB |
| 最終ジャッジ日時 | 2024-06-23 09:53:59 |
| 合計ジャッジ時間 | 5,447 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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
ソースコード
import Control.Applicative
import Text.Printf
main = do
[sn, sp] <- words <$> getLine
let
n = (read :: String -> Int) sn
p = (read :: String -> Double) sp
in
print $ solve n p
solve :: Int -> Double -> Double
solve n p = solve_ 2 [1.0,1.0 ..]
where
solve_ :: Int -> [Double] -> Double
solve_ i (x:xs)
| i == n = x
| otherwise = (+x) $ solve_ (i+1) $ app (\y->y*(1.0 - p)) (i+1) i xs
app :: (Double -> Double) -> Int -> Int -> [Double] -> [Double]
app f i m ys@(x:xs)
| i > n = ys
| otherwise = if i `mod` m == 0
then (f x) : app f (i+1) m xs
else x: app f (i+1) m xs
okaduki