結果

問題 No.48 ロボットの操縦
ユーザー l1267976l1267976
提出日時 2017-03-09 15:43:16
言語 Java19
(openjdk 21)
結果
AC  
実行時間 125 ms / 5,000 ms
コード長 616 bytes
コンパイル時間 8,079 ms
コンパイル使用メモリ 71,608 KB
実行使用メモリ 56,348 KB
最終ジャッジ日時 2023-09-06 05:25:24
合計ジャッジ時間 7,359 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 119 ms
55,636 KB
testcase_01 AC 120 ms
55,516 KB
testcase_02 AC 118 ms
55,924 KB
testcase_03 AC 120 ms
55,976 KB
testcase_04 AC 122 ms
55,728 KB
testcase_05 AC 121 ms
55,776 KB
testcase_06 AC 120 ms
55,888 KB
testcase_07 AC 122 ms
56,264 KB
testcase_08 AC 121 ms
55,720 KB
testcase_09 AC 122 ms
56,112 KB
testcase_10 AC 122 ms
55,948 KB
testcase_11 AC 120 ms
55,732 KB
testcase_12 AC 122 ms
56,348 KB
testcase_13 AC 122 ms
55,980 KB
testcase_14 AC 119 ms
56,056 KB
testcase_15 AC 124 ms
56,092 KB
testcase_16 AC 120 ms
55,740 KB
testcase_17 AC 121 ms
55,612 KB
testcase_18 AC 121 ms
55,848 KB
testcase_19 AC 122 ms
56,124 KB
testcase_20 AC 122 ms
56,068 KB
testcase_21 AC 119 ms
56,160 KB
testcase_22 AC 120 ms
55,880 KB
testcase_23 AC 125 ms
55,968 KB
testcase_24 AC 121 ms
55,928 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class No48 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        int l = sc.nextInt();

        int cnt = 0;

        int xMove = Math.abs(x / l);
        if (x % l != 0) xMove++;
        cnt += xMove;

        int yMove = Math.abs(y / l);
        if (y % l != 0) yMove++;
        cnt += yMove;

        if (x != 0 && y >= 0) {
            cnt++;
        }

        if (y < 0) {
            cnt += 2;
        }

        System.out.println(cnt);

        sc.close();
    }

}
0