結果
| 問題 |
No.48 ロボットの操縦
|
| コンテスト | |
| ユーザー |
Hirotaka Ohkubo
|
| 提出日時 | 2016-07-19 19:11:23 |
| 言語 | Haskell (9.10.1) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 554 bytes |
| コンパイル時間 | 3,552 ms |
| コンパイル使用メモリ | 176,384 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-21 18:44:31 |
| 合計ジャッジ時間 | 4,348 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / 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
ソースコード
main = do
x <- readLn
y <- readLn
l <- readLn
print $ compute x y l
compute :: Int -> Int -> Int -> Int
{-
compute x y l = inner (compare y 0) (compare x 0) where
inner GT EQ = yl
inner GT _ = yl + 1 + xl
inner LT EQ = 2 + yl
inner LT _ = 1 + xl + 1 + yl
inner EQ EQ = 0
inner EQ _ = 1 + xl
xl = steps x l
yl = steps y l
-}
compute x y l =
if y < 0 then xl + yl + 2 else
if x == 0 then yl else xl + yl + 1
where
xl = steps x l
yl = steps y l
steps x l = let (p,q) = divMod (abs x) l in if q == 0 then p else p+1
Hirotaka Ohkubo