結果

問題 No.48 ロボットの操縦
ユーザー Hirotaka OhkuboHirotaka Ohkubo
提出日時 2016-07-19 19:11:23
言語 Haskell
(9.8.2)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 554 bytes
コンパイル時間 10,475 ms
コンパイル使用メモリ 174,976 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-01 13:58:26
合計ジャッジ時間 5,709 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,248 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 1 ms
5,376 KB
testcase_13 AC 1 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 1 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 1 ms
5,376 KB
testcase_18 AC 1 ms
5,376 KB
testcase_19 AC 1 ms
5,376 KB
testcase_20 AC 1 ms
5,376 KB
testcase_21 AC 1 ms
5,376 KB
testcase_22 AC 2 ms
5,376 KB
testcase_23 AC 1 ms
5,376 KB
testcase_24 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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

ソースコード

diff #

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
0