結果
| 問題 |
No.346 チワワ数え上げ問題
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-05-06 15:33:36 |
| 言語 | Haskell (9.10.1) |
| 結果 |
AC
|
| 実行時間 | 13 ms / 2,000 ms |
| コード長 | 481 bytes |
| コンパイル時間 | 4,450 ms |
| コンパイル使用メモリ | 180,012 KB |
| 実行使用メモリ | 13,696 KB |
| 最終ジャッジ日時 | 2024-06-28 02:09:02 |
| 合計ジャッジ時間 | 5,363 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 |
コンパイルメッセージ
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.ByteString.Char8 (ByteString)
import qualified Data.ByteString.Char8 as B
main :: IO ()
main = solve <$> B.getLine >>= print
solve :: ByteString -> Int
solve = snd . B.foldr f (0, 0)
where f x (w, cww) | x == 'w' = (w+1, cww)
| x == 'c' = (w, comb w 2 + cww)
| otherwise = (w, cww)
comb n m | n < m = 0
| m == 0 || n == m = 1
| otherwise = comb (n-1) (m-1) * n `div` m