結果
問題 | No.894 二種類のバス |
ユーザー | 情報学生 |
提出日時 | 2019-09-27 23:05:15 |
言語 | Haskell (9.8.2) |
結果 |
CE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 1,061 bytes |
コンパイル時間 | 552 ms |
コンパイル使用メモリ | 143,084 KB |
最終ジャッジ日時 | 2023-10-25 05:50:32 |
合計ジャッジ時間 | 1,057 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge15 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.6.2/environments/default [1 of 2] Compiling Main ( Main.hs, Main.o ) Main.hs:6:1: error: Could not load module ‘Data.ByteString.Char8’ It is a member of the hidden package ‘bytestring-0.11.4.0’. You can run ‘:set -package bytestring’ to expose it. (Note: this unloads all the modules in the current scope.) Use -v (or `:set -v` in ghci) to see a list of the files searched for. | 6 | import qualified Data.ByteString.Char8 as BSC8 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ソースコード
--import Control.Applicative ((<$>)) import Control.Monad (replicateM) import Prelude hiding (lcm) import Data.Char (isSpace) import Data.List (transpose, unfoldr) import qualified Data.ByteString.Char8 as BSC8 getLL :: (BSC8.ByteString -> [Integer]) -> IO [Integer] getLL f = f <$> BSC8.getLine readILL :: (BSC8.ByteString -> Maybe (Integer, BSC8.ByteString)) -> (BSC8.ByteString -> [Integer]) readILL f = unfoldr g where g s = do (n, s') <- f s return (n, BSC8.dropWhile isSpace s') main :: IO () main = do [t, a, b] <- getLL (readILL BSC8.readInteger) print $ solve t a b solve :: Integer -> Integer -> Integer -> Integer solve t a b = aa + bb - cc where c = lcm a b aa = if t `mod` a == 0 then (t `div` a) else (t `div` a) + 1 bb = if t `mod` b == 0 then (t `div` b) else (t `div` b) + 1 cc = if c >= t then 1 else if t `mod` c == 0 then (t `div` c) else (t `div` c) + 1 lcm :: Integer -> Integer -> Integer lcm a b = a `div` (gcd a b) * b