結果

問題 No.48 ロボットの操縦
ユーザー Hiroaki KonoHiroaki Kono
提出日時 2017-10-26 23:02:12
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 626 bytes
コンパイル時間 3,226 ms
コンパイル使用メモリ 74,372 KB
実行使用メモリ 41,736 KB
最終ジャッジ日時 2024-05-01 15:19:58
合計ジャッジ時間 6,850 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
41,140 KB
testcase_01 AC 117 ms
41,248 KB
testcase_02 AC 118 ms
41,188 KB
testcase_03 WA -
testcase_04 AC 108 ms
40,352 KB
testcase_05 AC 114 ms
41,288 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 115 ms
41,004 KB
testcase_21 AC 116 ms
41,004 KB
testcase_22 AC 105 ms
40,196 KB
testcase_23 AC 106 ms
40,076 KB
testcase_24 AC 116 ms
41,048 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.text.DecimalFormat;
import java.util.Scanner;

public class No48 {

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

        int turn = 0;
        turn += x != 0 && y < 0 ? 1 : 0;
        turn += x == 0 && y < 0 ? 2 : 0;
        turn += x != 0 && y != 0 ? 1 : 0;

        x = Math.abs(x);
        y = Math.abs(y);

        String steps = new DecimalFormat("")
            .format(Math.ceil((double) x / l) + Math.ceil((double) y / l) + turn);
        System.out.println(steps);
    }
}
0