結果

問題 No.48 ロボットの操縦
ユーザー aaaaasatoriaaaaasatori
提出日時 2018-02-05 11:53:37
言語 Java19
(openjdk 21)
結果
AC  
実行時間 125 ms / 5,000 ms
コード長 597 bytes
コンパイル時間 3,121 ms
コンパイル使用メモリ 72,172 KB
実行使用メモリ 56,480 KB
最終ジャッジ日時 2023-09-21 08:24:43
合計ジャッジ時間 7,322 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
55,972 KB
testcase_01 AC 123 ms
56,324 KB
testcase_02 AC 125 ms
55,784 KB
testcase_03 AC 123 ms
55,916 KB
testcase_04 AC 123 ms
56,048 KB
testcase_05 AC 122 ms
56,116 KB
testcase_06 AC 122 ms
55,540 KB
testcase_07 AC 123 ms
55,796 KB
testcase_08 AC 122 ms
56,292 KB
testcase_09 AC 121 ms
56,108 KB
testcase_10 AC 121 ms
55,856 KB
testcase_11 AC 121 ms
55,784 KB
testcase_12 AC 121 ms
55,552 KB
testcase_13 AC 122 ms
56,340 KB
testcase_14 AC 121 ms
55,960 KB
testcase_15 AC 121 ms
55,960 KB
testcase_16 AC 123 ms
55,700 KB
testcase_17 AC 122 ms
55,788 KB
testcase_18 AC 121 ms
55,760 KB
testcase_19 AC 121 ms
56,332 KB
testcase_20 AC 122 ms
56,124 KB
testcase_21 AC 122 ms
56,024 KB
testcase_22 AC 122 ms
56,480 KB
testcase_23 AC 122 ms
56,348 KB
testcase_24 AC 121 ms
55,808 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(); //x座標
		int Y = sc.nextInt(); //y座標
		int L = sc.nextInt(); //一度に動ける距離
		int count = 0; //命令した回数
		
		if(X % L == 0) {
			count += Math.abs(X) / L;
		}else {
			count += Math.abs(X) / L + 1;
		}
		
		if(Y % L == 0) {
			count += Math.abs(Y) / L;
		}else {
			count += Math.abs(Y) / L + 1;
		}
		
		if(X != 0 && Y >= 0) {
			count++;
		}else if(Y < 0) {
			count += 2;
		}
		
		System.out.println(count);
	}
}
0