結果

問題 No.48 ロボットの操縦
ユーザー jimanojimano
提出日時 2018-01-07 17:22:19
言語 Java19
(openjdk 21)
結果
AC  
実行時間 133 ms / 5,000 ms
コード長 586 bytes
コンパイル時間 4,763 ms
コンパイル使用メモリ 72,624 KB
実行使用メモリ 56,292 KB
最終ジャッジ日時 2023-08-24 23:35:32
合計ジャッジ時間 8,179 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
55,708 KB
testcase_01 AC 125 ms
55,900 KB
testcase_02 AC 126 ms
55,704 KB
testcase_03 AC 124 ms
55,700 KB
testcase_04 AC 123 ms
55,764 KB
testcase_05 AC 122 ms
53,820 KB
testcase_06 AC 123 ms
55,992 KB
testcase_07 AC 123 ms
55,628 KB
testcase_08 AC 122 ms
55,692 KB
testcase_09 AC 131 ms
55,584 KB
testcase_10 AC 124 ms
55,988 KB
testcase_11 AC 124 ms
56,000 KB
testcase_12 AC 124 ms
55,948 KB
testcase_13 AC 124 ms
55,796 KB
testcase_14 AC 126 ms
55,848 KB
testcase_15 AC 124 ms
55,632 KB
testcase_16 AC 133 ms
55,944 KB
testcase_17 AC 122 ms
55,656 KB
testcase_18 AC 123 ms
55,608 KB
testcase_19 AC 123 ms
56,152 KB
testcase_20 AC 126 ms
56,012 KB
testcase_21 AC 126 ms
56,292 KB
testcase_22 AC 125 ms
56,044 KB
testcase_23 AC 125 ms
55,732 KB
testcase_24 AC 124 ms
55,720 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class No0048 {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int Y = sc.nextInt();
		int L = sc.nextInt();

		System.out.println(turnCount(X, Y) + aheadCount(X, Y, L));
	}

	static int turnCount(int x, int y) {
		if (y >= 0) {
			if (x == 0) {
				return 0;
			}
			return 1;
		} else {
			return 2;
		}
	}

	static int aheadCount(int x, int y, int l) {
		int cnt = (Math.abs(x) / l) + (Math.abs(y) / l);
		if (x % l != 0) {
			cnt++;
		}
		if (y % l != 0) {
			cnt++;
		}
		return cnt;
	}
}
0