結果
問題 |
No.162 8020運動
|
ユーザー |
|
提出日時 | 2015-03-07 00:09:15 |
言語 | Haskell (9.10.1) |
結果 |
AC
|
実行時間 | 9 ms / 5,000 ms |
コード長 | 782 bytes |
コンパイル時間 | 4,799 ms |
コンパイル使用メモリ | 193,116 KB |
実行使用メモリ | 8,320 KB |
最終ジャッジ日時 | 2024-06-24 14:48:53 |
合計ジャッジ時間 | 5,900 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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
ソースコード
import Control.Applicative import Data.List import Data.Array 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 n m | m==0 || m==n+1 = 1 | n==1 && m==1 = a | m==1 || m==n = b | otherwise = c sub nn m [i,j] = foldl (*) ((dp!(nn,(j-i+1)))*(pa m (i-1))*(pa m (j+1))) $ map ((1-).(pa m)) [i..j] calc 0 m = fromIntegral m calc nn m = foldl1 (+) $ map (sub (nn-1) m) $ repeated_combination [1..m] 2 dp = array ((0,0),(n,14)) [((i,j),calc i j)|i<-[0..n],j<-[0..14]] in print $ (dp!(n,14))*2