結果

問題 No.48 ロボットの操縦
ユーザー aaaaasatoriaaaaasatori
提出日時 2018-02-05 11:53:37
言語 Java
(openjdk 23)
結果
AC  
実行時間 116 ms / 5,000 ms
コード長 597 bytes
コンパイル時間 3,145 ms
コンパイル使用メモリ 75,296 KB
実行使用メモリ 54,276 KB
最終ジャッジ日時 2024-07-07 02:46:18
合計ジャッジ時間 6,693 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

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