結果

問題 No.162 8020運動
ユーザー gigurururu
提出日時 2015-03-06 23:33:54
言語 Haskell
(9.10.1)
結果
AC  
実行時間 7 ms / 5,000 ms
コード長 643 bytes
コンパイル時間 4,795 ms
コンパイル使用メモリ 171,392 KB
実行使用メモリ 7,552 KB
最終ジャッジ日時 2024-06-24 14:45:48
合計ジャッジ時間 6,065 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 26
権限があれば一括ダウンロードができます
コンパイルメッセージ
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
import Data.List

repeated_combination ns n = comb n [(ns,[])]
  where
    comb 0 xs = [a|(_,a)<-xs]
    comb c xs = comb (c-1) $ concatMap f xs
    f (xs,ys) = [(as,ys++[a])|as@(a:_)<-tails xs]

main = do
  n <- (80-).read <$> getLine
  [a,b,c] <- map ((/100).read) . words <$> getLine
  let pa 0 = [1,1]
      pa 1 = [1,a,1]
      pa n = [1,b]++(replicate (n-2) c)++[b,1]
      update s n = foldl (sub s $ pa n) 0 $ repeated_combination [1..n] 2
      sub s p t [i,j] = t+(foldl (\u k->u*(1-p!!k)) (s!!(j-i+1)*p!!(i-1)*p!!(j+1)) [i..j])
    in print $ ((foldl (\s _->map (update s) [0..14]) [0..14] [1..n])!!14)*2
0