結果

問題 No.346 チワワ数え上げ問題
ユーザー TatsunoTatsuno
提出日時 2016-02-26 23:15:59
言語 Haskell
(9.8.2)
結果
TLE  
実行時間 -
コード長 355 bytes
コンパイル時間 6,786 ms
コンパイル使用メモリ 166,232 KB
実行使用メモリ 22,064 KB
最終ジャッジ日時 2023-10-24 06:17:53
合計ジャッジ時間 7,224 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,048 KB
testcase_01 AC 3 ms
4,968 KB
testcase_02 AC 2 ms
4,936 KB
testcase_03 AC 2 ms
4,944 KB
testcase_04 AC 2 ms
5,020 KB
testcase_05 AC 2 ms
4,932 KB
testcase_06 AC 2 ms
5,012 KB
testcase_07 AC 3 ms
4,980 KB
testcase_08 AC 2 ms
4,992 KB
testcase_09 AC 3 ms
5,052 KB
testcase_10 TLE -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.6.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
          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