結果

問題 No.48 ロボットの操縦
ユーザー jimano
提出日時 2018-01-07 17:26:32
言語 Java
(openjdk 23)
結果
AC  
実行時間 154 ms / 5,000 ms
コード長 541 bytes
コンパイル時間 3,699 ms
コンパイル使用メモリ 74,900 KB
実行使用メモリ 41,612 KB
最終ジャッジ日時 2024-12-23 10:11:07
合計ジャッジ時間 8,624 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

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