結果

問題 No.48 ロボットの操縦
ユーザー jimanojimano
提出日時 2018-01-07 17:19:48
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 585 bytes
コンパイル時間 3,306 ms
コンパイル使用メモリ 72,360 KB
実行使用メモリ 56,484 KB
最終ジャッジ日時 2023-08-24 23:35:20
合計ジャッジ時間 8,225 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
55,728 KB
testcase_01 AC 124 ms
55,908 KB
testcase_02 AC 127 ms
55,704 KB
testcase_03 AC 128 ms
55,748 KB
testcase_04 AC 125 ms
55,736 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 126 ms
56,040 KB
testcase_08 AC 125 ms
55,696 KB
testcase_09 AC 125 ms
55,416 KB
testcase_10 AC 125 ms
55,644 KB
testcase_11 AC 125 ms
55,772 KB
testcase_12 AC 126 ms
55,704 KB
testcase_13 AC 123 ms
55,588 KB
testcase_14 AC 123 ms
56,264 KB
testcase_15 AC 124 ms
55,720 KB
testcase_16 AC 124 ms
55,760 KB
testcase_17 AC 124 ms
53,916 KB
testcase_18 AC 124 ms
56,008 KB
testcase_19 AC 124 ms
55,732 KB
testcase_20 AC 125 ms
55,736 KB
testcase_21 AC 124 ms
55,780 KB
testcase_22 AC 124 ms
55,748 KB
testcase_23 AC 123 ms
55,692 KB
testcase_24 AC 126 ms
55,900 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