結果
| 問題 | No.423 ハムスター語初級(数詞) |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-10-07 04:55:33 |
| 言語 | Haskell (9.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 759 bytes |
| 記録 | |
| コンパイル時間 | 4,548 ms |
| コンパイル使用メモリ | 194,432 KB |
| 実行使用メモリ | 7,972 KB |
| 最終ジャッジ日時 | 2026-05-15 22:50:49 |
| 合計ジャッジ時間 | 5,490 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 1 |
| other | WA * 8 RE * 1 |
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.14.1/environments/default [1 of 2] Compiling Main ( Main.hs, Main.o ) [2 of 2] Linking a.out
ソースコード
import Numeric (showIntAtBase)
import Data.Char (intToDigit)
main :: IO ()
main = getLine >>= putStrLn . retranslate . toTwoBase . addOne . toTenBase . translate . check
check :: String -> String
check ('h':'a':'m':'u':x) = ('h':'a':'m':'u':x)
check _ = error "Not a number"
translate :: String -> [Int]
translate [] = []
translate ('h':'a':'m':'u':x) = 1 : (translate x)
translate ('h':'a':'m':x) = 0 : (translate x)
multiply :: Int -> Int -> Int
multiply a b = a * 2 + b
toTenBase :: [Int] -> Int
toTenBase = foldl (multiply) 0
addOne :: Int -> Int
addOne x = 1 + x
toTwoBase :: Int -> String
toTwoBase x = (showIntAtBase 2 intToDigit x "") ++ ""
retranslate :: [Char] -> String
retranslate x = concat [if x == '1' then "hamu" else "ham" | x <- x ]