結果

問題 No.405 ローマ数字の腕時計
ユーザー ducktailducktail
提出日時 2018-01-14 20:08:17
言語 Haskell
(9.8.2)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 772 bytes
コンパイル時間 959 ms
コンパイル使用メモリ 164,848 KB
実行使用メモリ 7,324 KB
最終ジャッジ日時 2023-09-21 00:31:28
合計ジャッジ時間 2,237 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
7,192 KB
testcase_01 AC 2 ms
7,180 KB
testcase_02 AC 2 ms
7,168 KB
testcase_03 AC 2 ms
7,032 KB
testcase_04 AC 2 ms
6,988 KB
testcase_05 AC 2 ms
6,972 KB
testcase_06 AC 2 ms
7,100 KB
testcase_07 AC 3 ms
7,136 KB
testcase_08 AC 2 ms
6,992 KB
testcase_09 AC 3 ms
7,160 KB
testcase_10 AC 2 ms
7,132 KB
testcase_11 AC 2 ms
7,212 KB
testcase_12 AC 2 ms
7,192 KB
testcase_13 AC 2 ms
7,128 KB
testcase_14 AC 2 ms
7,188 KB
testcase_15 AC 2 ms
7,240 KB
testcase_16 AC 2 ms
7,184 KB
testcase_17 AC 3 ms
7,240 KB
testcase_18 AC 2 ms
7,320 KB
testcase_19 AC 2 ms
7,100 KB
testcase_20 AC 2 ms
7,300 KB
testcase_21 AC 3 ms
7,188 KB
testcase_22 AC 2 ms
7,324 KB
testcase_23 AC 2 ms
7,056 KB
testcase_24 AC 2 ms
7,228 KB
testcase_25 AC 2 ms
7,260 KB
testcase_26 AC 2 ms
7,172 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.Applicative ((<$>))

main :: IO ()
main = do
  solve <$> getl words >>= putStrLn

solve :: [String] -> String
solve [s1, st] = let t = read st
                 in toRoman . (`mod` 12) $ fromRoman s1 + t 

toRoman :: Int -> String
toRoman 1 = "I"
toRoman 2 = "II"
toRoman 3 = "III"
toRoman 4 = "IIII"
toRoman 5 = "V"
toRoman 6 = "VI"
toRoman 7 = "VII"
toRoman 8 = "VIII"
toRoman 9 = "IX"
toRoman 10 = "X"
toRoman 11 = "XI"
toRoman 0 = "XII"

fromRoman :: String -> Int
fromRoman "I" = 1
fromRoman "II" = 2
fromRoman "III" = 3
fromRoman "IIII" = 4
fromRoman "V" = 5
fromRoman "VI" = 6
fromRoman "VII" = 7
fromRoman "VIII" = 8
fromRoman "IX" = 9
fromRoman "X" = 10
fromRoman "XI" = 11
fromRoman "XII" = 12

getl :: (String -> a) -> IO a
getl f = f <$> getLine
0