結果

問題 No.346 チワワ数え上げ問題
ユーザー はむ吉🐹はむ吉🐹
提出日時 2016-02-27 18:03:21
言語 Haskell
(9.8.2)
結果
AC  
実行時間 23 ms / 2,000 ms
コード長 381 bytes
コンパイル時間 7,019 ms
コンパイル使用メモリ 169,044 KB
実行使用メモリ 14,172 KB
最終ジャッジ日時 2023-10-24 18:36:41
合計ジャッジ時間 8,143 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,232 KB
testcase_01 AC 2 ms
5,176 KB
testcase_02 AC 2 ms
5,136 KB
testcase_03 AC 2 ms
5,144 KB
testcase_04 AC 3 ms
5,220 KB
testcase_05 AC 2 ms
5,004 KB
testcase_06 AC 2 ms
5,204 KB
testcase_07 AC 2 ms
5,184 KB
testcase_08 AC 2 ms
5,200 KB
testcase_09 AC 2 ms
5,236 KB
testcase_10 AC 22 ms
14,040 KB
testcase_11 AC 12 ms
10,656 KB
testcase_12 AC 22 ms
13,000 KB
testcase_13 AC 13 ms
10,488 KB
testcase_14 AC 3 ms
5,604 KB
testcase_15 AC 22 ms
12,692 KB
testcase_16 AC 23 ms
13,180 KB
testcase_17 AC 22 ms
13,992 KB
testcase_18 AC 23 ms
13,996 KB
testcase_19 AC 22 ms
13,352 KB
testcase_20 AC 22 ms
13,924 KB
testcase_21 AC 23 ms
14,172 KB
testcase_22 AC 22 ms
14,172 KB
testcase_23 AC 3 ms
5,132 KB
testcase_24 AC 3 ms
5,004 KB
testcase_25 AC 2 ms
5,136 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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 #

combi :: Integral a => a -> a
combi n = n * (n - 1) `div` 2

solve :: Integral a => String -> a
solve = sol 0 0 . reverse
    where
        sol w a [] = a
        sol w a (c : cs)
            | c == 'w'          = sol (w + 1) a cs
            | c == 'c' && w > 0 = sol w (a + combi w) cs
            | otherwise         = sol w a cs

main :: IO ()
main = print . solve =<< getLine
0