結果

問題 No.423 ハムスター語初級(数詞)
ユーザー NaruYNaruY
提出日時 2018-02-15 21:57:50
言語 Haskell
(9.8.2)
結果
WA  
実行時間 -
コード長 819 bytes
コンパイル時間 1,237 ms
コンパイル使用メモリ 163,316 KB
実行使用メモリ 7,204 KB
最終ジャッジ日時 2023-08-28 14:27:02
合計ジャッジ時間 2,140 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
7,116 KB
testcase_01 AC 3 ms
7,100 KB
testcase_02 AC 3 ms
7,024 KB
testcase_03 AC 3 ms
7,036 KB
testcase_04 AC 2 ms
7,064 KB
testcase_05 WA -
testcase_06 AC 3 ms
7,076 KB
testcase_07 AC 2 ms
7,204 KB
testcase_08 AC 2 ms
7,160 KB
testcase_09 AC 3 ms
7,056 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.6.1/environments/default
[1 of 2] Compiling Main             ( Main.hs, Main.o )
[2 of 2] Linking a.out

ソースコード

diff #

import Control.Monad
import Control.Applicative
import Data.List
import qualified Data.Map as Map
import Data.Array
import qualified Data.ByteString.Char8 as BC
import Data.Maybe
strToInt s = (read :: String -> Int) s
b2i xs = foldl (\x y -> 2 * x + y) 0 $ map (\x -> read [x]) xs
i2b = concat . (map show) . reverse . i2b' where i2b' 0 = []; i2b' n = mod n 2 : i2b' (div n 2)

main = do
    ham <- getLine
    let answ1 = show $ i2b $ 2 * (b2i $ conv ham)
    let answ2 = foldr (++) [] (map ans answ1)
    putStrLn $ answ2
    
ans :: Char -> String
ans '0' = "ham"
ans '1' = "hamu"
ans _ = ""

conv :: String -> String
conv [] = []
conv ham = if (length ham) <= 3
           then "0"
           else if (take 4 ham) == "hamu"
                then "1" ++ conv (drop 4 ham)
                else "0" ++ conv (drop 3 ham)
0