結果

問題 No.48 ロボットの操縦
ユーザー tanson
提出日時 2025-07-22 00:47:11
言語 Standard ML
(MLton 20210117)
結果
AC  
実行時間 1 ms / 5,000 ms
コード長 854 bytes
コンパイル時間 3,358 ms
コンパイル使用メモリ 688,632 KB
実行使用メモリ 7,720 KB
最終ジャッジ日時 2025-07-22 00:47:19
合計ジャッジ時間 4,238 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

fun readInt () =
    valOf (TextIO.scanStream (Int.scan StringCvt.DEC) TextIO.stdIn)

fun findAns 0 0 _ = 0
  | findAns 0 y l = if 0 < y then (y + l - 1) div l
                    else ((abs y + l - 1) div l) + 2
  | findAns x 0 l = ((abs x + l - 1) div l) + 1
  | findAns x y l = if 0 < x andalso 0 < y then ((y + l - 1) div l) + ((x + l - 1) div l) + 1
                    else if 0 < x andalso y < 0 then ((x + l - 1) div l) + 1 + ((abs y + l - 1) div l) + 1
                    else if x < 0 andalso 0 < y then ((y + l - 1) div l) + ((abs x + l - 1) div l) + 1
                    else (* x < 0 andalso y < 0 *) ((abs x + l - 1) div l) + 1 + ((abs y + l - 1) div l) + 1

val () =
    let
        val x = readInt ()
        val y = readInt ()
        val l = readInt ()

        val ans = findAns x y l
    in
        print (Int.toString ans)
    end
0