結果

問題 No.405 ローマ数字の腕時計
ユーザー ducktailducktail
提出日時 2018-01-14 20:06:28
言語 Haskell
(9.8.2)
結果
RE  
実行時間 -
コード長 773 bytes
コンパイル時間 827 ms
コンパイル使用メモリ 165,080 KB
実行使用メモリ 7,436 KB
最終ジャッジ日時 2023-08-25 17:33:49
合計ジャッジ時間 2,285 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
7,196 KB
testcase_01 AC 3 ms
7,256 KB
testcase_02 AC 3 ms
7,276 KB
testcase_03 AC 2 ms
7,040 KB
testcase_04 AC 3 ms
7,080 KB
testcase_05 AC 3 ms
7,028 KB
testcase_06 RE -
testcase_07 AC 2 ms
7,132 KB
testcase_08 AC 2 ms
7,060 KB
testcase_09 RE -
testcase_10 AC 3 ms
7,240 KB
testcase_11 AC 3 ms
7,236 KB
testcase_12 RE -
testcase_13 AC 2 ms
7,224 KB
testcase_14 AC 2 ms
7,192 KB
testcase_15 AC 2 ms
7,276 KB
testcase_16 AC 2 ms
7,188 KB
testcase_17 RE -
testcase_18 AC 2 ms
7,280 KB
testcase_19 AC 2 ms
7,232 KB
testcase_20 AC 2 ms
7,264 KB
testcase_21 AC 2 ms
7,144 KB
testcase_22 AC 2 ms
7,212 KB
testcase_23 AC 2 ms
7,108 KB
testcase_24 AC 2 ms
7,236 KB
testcase_25 RE -
testcase_26 RE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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 12 = "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