結果
| 問題 |
No.48 ロボットの操縦
|
| コンテスト | |
| ユーザー |
yutasth
|
| 提出日時 | 2017-05-04 20:22:54 |
| 言語 | Haskell (9.10.1) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 405 bytes |
| コンパイル時間 | 1,818 ms |
| コンパイル使用メモリ | 172,160 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-14 07:14:54 |
| 合計ジャッジ時間 | 2,641 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 25 |
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.8.2/environments/default [1 of 2] Compiling Main ( Main.hs, Main.o ) [2 of 2] Linking a.out
ソースコード
import Prelude
main :: IO ()
main = do
[x, y, l] <- map read . lines <$> getContents
print $ calc x y l
calc :: Int -> Int -> Int -> Int
calc x y l = turns x y + over (abs x) l + over (abs y) l
turns :: Int -> Int -> Int
turns x y | x == 0 && y >= 0 = 0
| y >= 0 = 1
| otherwise = 2
over :: Int -> Int -> Int
over x l = div x l + if mod x l == 0 then 0 else 1
yutasth