結果

問題 No.48 ロボットの操縦
ユーザー Hirotaka OhkuboHirotaka Ohkubo
提出日時 2016-07-19 19:11:23
言語 Haskell
(9.8.2)
結果
AC  
実行時間 3 ms / 5,000 ms
コード長 554 bytes
コンパイル時間 4,935 ms
コンパイル使用メモリ 163,932 KB
実行使用メモリ 7,048 KB
最終ジャッジ日時 2023-08-14 00:43:31
合計ジャッジ時間 6,202 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,852 KB
testcase_01 AC 2 ms
6,996 KB
testcase_02 AC 3 ms
6,964 KB
testcase_03 AC 2 ms
7,028 KB
testcase_04 AC 2 ms
6,908 KB
testcase_05 AC 3 ms
6,896 KB
testcase_06 AC 2 ms
6,964 KB
testcase_07 AC 3 ms
6,912 KB
testcase_08 AC 3 ms
6,944 KB
testcase_09 AC 2 ms
6,984 KB
testcase_10 AC 2 ms
7,016 KB
testcase_11 AC 2 ms
7,048 KB
testcase_12 AC 2 ms
6,848 KB
testcase_13 AC 2 ms
7,048 KB
testcase_14 AC 3 ms
6,912 KB
testcase_15 AC 2 ms
6,924 KB
testcase_16 AC 3 ms
6,924 KB
testcase_17 AC 3 ms
6,904 KB
testcase_18 AC 3 ms
6,992 KB
testcase_19 AC 3 ms
6,904 KB
testcase_20 AC 3 ms
6,968 KB
testcase_21 AC 2 ms
6,960 KB
testcase_22 AC 2 ms
7,024 KB
testcase_23 AC 2 ms
6,984 KB
testcase_24 AC 3 ms
6,908 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.6.1/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