結果
問題 | No.423 ハムスター語初級(数詞) |
ユーザー |
|
提出日時 | 2016-10-07 05:04:06 |
言語 | Haskell (9.10.1) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 776 bytes |
コンパイル時間 | 1,496 ms |
コンパイル使用メモリ | 172,672 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-21 19:03:22 |
合計ジャッジ時間 | 1,997 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 9 |
コンパイルメッセージ
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 . goTwo . toTenBase . translate . checkcheck::String->Stringcheck ('h':'a':'m':'u':x) = ('h':'a':'m':'u':x)check "ham" = "ham"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) 0goTwo::Int->IntgoTwo x = 2 * xtoTwoBase::Int->StringtoTwoBase x = (showIntAtBase 2 intToDigit x "") ++ ""retranslate::Char->Stringretranslate x = concat [if x == '1' then "hamu" else "ham" | x <- x ]