結果

問題 No.48 ロボットの操縦
ユーザー jimanojimano
提出日時 2018-01-07 17:26:32
言語 Java21
(openjdk 21)
結果
AC  
実行時間 128 ms / 5,000 ms
コード長 541 bytes
コンパイル時間 5,456 ms
コンパイル使用メモリ 72,212 KB
実行使用メモリ 56,320 KB
最終ジャッジ日時 2023-08-24 23:36:26
合計ジャッジ時間 7,679 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
56,032 KB
testcase_01 AC 124 ms
55,772 KB
testcase_02 AC 127 ms
56,060 KB
testcase_03 AC 124 ms
56,204 KB
testcase_04 AC 124 ms
55,652 KB
testcase_05 AC 123 ms
55,664 KB
testcase_06 AC 122 ms
55,704 KB
testcase_07 AC 122 ms
55,472 KB
testcase_08 AC 124 ms
55,664 KB
testcase_09 AC 124 ms
55,392 KB
testcase_10 AC 124 ms
56,320 KB
testcase_11 AC 124 ms
55,472 KB
testcase_12 AC 124 ms
55,664 KB
testcase_13 AC 124 ms
55,704 KB
testcase_14 AC 127 ms
55,752 KB
testcase_15 AC 128 ms
55,652 KB
testcase_16 AC 123 ms
55,660 KB
testcase_17 AC 124 ms
55,636 KB
testcase_18 AC 124 ms
55,904 KB
testcase_19 AC 124 ms
55,400 KB
testcase_20 AC 126 ms
55,988 KB
testcase_21 AC 126 ms
55,896 KB
testcase_22 AC 123 ms
55,844 KB
testcase_23 AC 125 ms
55,656 KB
testcase_24 AC 125 ms
55,748 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, L) + aheadCount(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 l) {
		int cnt = (Math.abs(x) / l);
		if (x % l != 0) {
			cnt++;
		}
		return cnt;
	}
}
0