結果

問題 No.48 ロボットの操縦
ユーザー tentententen
提出日時 2020-11-10 12:23:36
言語 Java21
(openjdk 21)
結果
AC  
実行時間 119 ms / 5,000 ms
コード長 540 bytes
コンパイル時間 1,848 ms
コンパイル使用メモリ 71,784 KB
実行使用メモリ 56,652 KB
最終ジャッジ日時 2023-09-29 23:27:15
合計ジャッジ時間 5,479 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 103 ms
55,920 KB
testcase_01 AC 105 ms
56,652 KB
testcase_02 AC 106 ms
56,068 KB
testcase_03 AC 105 ms
56,464 KB
testcase_04 AC 119 ms
56,204 KB
testcase_05 AC 111 ms
56,148 KB
testcase_06 AC 113 ms
56,200 KB
testcase_07 AC 116 ms
56,344 KB
testcase_08 AC 113 ms
56,320 KB
testcase_09 AC 108 ms
56,212 KB
testcase_10 AC 114 ms
56,144 KB
testcase_11 AC 107 ms
55,604 KB
testcase_12 AC 108 ms
56,612 KB
testcase_13 AC 109 ms
56,396 KB
testcase_14 AC 107 ms
53,916 KB
testcase_15 AC 110 ms
56,056 KB
testcase_16 AC 109 ms
56,064 KB
testcase_17 AC 110 ms
56,108 KB
testcase_18 AC 110 ms
56,168 KB
testcase_19 AC 109 ms
56,496 KB
testcase_20 AC 112 ms
56,276 KB
testcase_21 AC 112 ms
55,940 KB
testcase_22 AC 105 ms
56,148 KB
testcase_23 AC 104 ms
56,060 KB
testcase_24 AC 109 ms
56,404 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = Math.abs(sc.nextInt());
        int y = sc.nextInt();
        int k = sc.nextInt();
        int ans = 0;
        if (y < 0) {
            ans++;
            y = -y;
            if (x == 0) {
                ans++;
            }
        }
        ans += (y + k - 1) / k;
        if (x != 0) {
            ans++;
        }
        ans += (x + k - 1) / k;
        System.out.println(ans);
    }
}
0