結果
問題 | No.423 ハムスター語初級(数詞) |
ユーザー |
|
提出日時 | 2016-10-07 04:55:33 |
言語 | Haskell (9.10.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 759 bytes |
コンパイル時間 | 4,408 ms |
コンパイル使用メモリ | 173,440 KB |
実行使用メモリ | 6,816 KB |
最終ジャッジ日時 | 2024-11-21 19:02:33 |
合計ジャッジ時間 | 4,961 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 1 |
other | WA * 8 RE * 1 |
コンパイルメッセージ
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
ソースコード
importNumericshowIntAtBaseimportData.CharintToDigitmain::IO()main = getLine >>= putStrLn . retranslate . toTwoBase . addOne . toTenBase . translate . checkcheck::String->Stringcheck ('h':'a':'m':'u':x) = ('h':'a':'m':'u':x)check _ = error "Not a number"translate::String->Inttranslate [] = []translate ('h':'a':'m':'u':x) = 1 : (translate x)translate ('h':'a':'m':x) = 0 : (translate x)multiply::Int->Int->Intmultiply a b = a * 2 + btoTenBase::Int->InttoTenBase = foldl (multiply) 0addOne::Int->IntaddOne x = 1 + xtoTwoBase::Int->StringtoTwoBase x = (showIntAtBase 2 intToDigit x "") ++ ""retranslate::Char->Stringretranslate x = concat [if x == '1' then "hamu" else "ham" | x <- x ]