結果

問題 No.346 チワワ数え上げ問題
ユーザー Tatsuno
提出日時 2016-02-26 23:11:56
言語 Haskell
(9.10.1)
結果
TLE  
実行時間 -
コード長 412 bytes
コンパイル時間 2,121 ms
コンパイル使用メモリ 176,956 KB
実行使用メモリ 19,616 KB
最終ジャッジ日時 2024-09-22 22:45:13
合計ジャッジ時間 5,758 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 3
other AC * 10 TLE * 1 -- * 12
権限があれば一括ダウンロードができます
コンパイルメッセージ
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 #

main :: IO ()
main = do s_ <- getLine
          let s = filter (\x -> x == 'c' || x== 'w') s_
          putStrLn . show $ f s

f :: String -> Int
f ('c':xs) | length s < 2 = 0
           | otherwise = bc (length s) 2 + f xs
    where s = filter ((==) 'w') xs
f (_:xs) = f xs
f _ = 0

bc :: Int -> Int -> Int
bc _ 0 = 1
bc n k | n < 0 = 0
       | n == k = 1
       | otherwise = bc (n - 1) (k - 1) + bc (n - 1) k
0