結果
問題 | No.518 ローマ数字の和 |
ユーザー |
![]() |
提出日時 | 2018-03-13 17:17:01 |
言語 | Haskell (9.10.1) |
結果 |
CE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 1,647 bytes |
コンパイル時間 | 158 ms |
コンパイル使用メモリ | 150,912 KB |
最終ジャッジ日時 | 2024-11-14 20:23:01 |
合計ジャッジ時間 | 650 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.8.2/environments/default [1 of 2] Compiling Main ( Main.hs, Main.o ) Main.hs:1:1: error: [GHC-87110] Could not load module ‘Text.Parsec’. It is a member of the hidden package ‘parsec-3.1.17.0’. Use -v to see a list of the files searched for. | 1 | import Text.Parsec | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ソースコード
importText.Parsecn4 = domn <- length <$> many (char 'M')n <- n3return $ mn * 1000 + nn3 = try n31 <|> try n32 <|> n33wheren31 = string "CD" >> (+ 400) <$> n2n32 = string "CM" >> (+ 900) <$> n2n33 = dod <- length <$> many (char 'D')cn <- length <$> many (char 'C')n <- n2return $ d * 500 + cn * 100 + nn2 = try n21 <|> try n22 <|> n23wheren21 = string "XL" >> (+ 40) <$> n1n22 = string "XC" >> (+ 90) <$> n1n23 = dol <- length <$> many (char 'L')xn <- length <$> many (char 'X')n <- n1return $ l * 50 + xn * 10 + nn1 = try n11 <|> try n12 <|> n13wheren11 = string "IV" >> return 4n12 = string "IX" >> return 9n13 = dov <- length <$> many (char 'V')i_n <- length <$> many (char 'I')return $ v * 5 + i_nm x| x >= 4000 = "ERROR"| otherwise = s4 ++ s3 ++ s2 ++ s1where[x1, x2, x3, x4] = take 4 $ map (`mod` 10) (iterate (`div` 10) x) ++ replicate 4 0f u1 u2 u3 x = if x == 9then [u1, u3]else if x >= 5then u2 : replicate (x - 5) u1else if x == 4then [u1, u2]else replicate x u1s4 = replicate x4 'M's3 = f 'C' 'D' 'M' x3s2 = f 'X' 'L' 'C' x2s1 = f 'I' 'V' 'X' x1main = do_ <- getLiners <- words <$> getLinelet parse' :: String -> Intparse' y = case parse n4 "" y ofLeft _ -> undefinedRight n -> nlet s = sum $ map parse' rsputStrLn $ m s