結果

問題 No.48 ロボットの操縦
ユーザー k_kadorak_kadora
提出日時 2015-05-21 10:51:29
言語 Java21
(openjdk 21)
結果
AC  
実行時間 142 ms / 5,000 ms
コード長 563 bytes
コンパイル時間 3,677 ms
コンパイル使用メモリ 75,012 KB
実行使用メモリ 41,336 KB
最終ジャッジ日時 2024-05-01 13:37:57
合計ジャッジ時間 8,032 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
40,148 KB
testcase_01 AC 135 ms
41,208 KB
testcase_02 AC 120 ms
39,940 KB
testcase_03 AC 142 ms
41,196 KB
testcase_04 AC 135 ms
41,128 KB
testcase_05 AC 134 ms
40,960 KB
testcase_06 AC 135 ms
41,208 KB
testcase_07 AC 134 ms
41,084 KB
testcase_08 AC 136 ms
41,236 KB
testcase_09 AC 136 ms
41,096 KB
testcase_10 AC 134 ms
41,084 KB
testcase_11 AC 135 ms
41,052 KB
testcase_12 AC 134 ms
41,176 KB
testcase_13 AC 132 ms
41,296 KB
testcase_14 AC 137 ms
41,336 KB
testcase_15 AC 133 ms
41,136 KB
testcase_16 AC 136 ms
41,268 KB
testcase_17 AC 134 ms
41,028 KB
testcase_18 AC 136 ms
41,200 KB
testcase_19 AC 136 ms
41,316 KB
testcase_20 AC 133 ms
41,080 KB
testcase_21 AC 121 ms
39,900 KB
testcase_22 AC 134 ms
40,984 KB
testcase_23 AC 136 ms
41,276 KB
testcase_24 AC 135 ms
41,256 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
public class Robot{
	public static void main(String[] arg){
		int x,y,l,res=0;
		Scanner sc = new Scanner(System.in);
		x = sc.nextInt();
		y = sc.nextInt();
		l = sc.nextInt();
		if(y>= 0 && x != 0){
			res++;
		}else if(y<0){
			res = res+2;
		}
		if((x != 0) && (Math.abs(x)%l == 0)){
			res = res + (Math.abs(x)/l);
		}else if (x != 0){
			res = res + (Math.abs(x)/l)+1;
		}
		if((y != 0) && (Math.abs(y) % l == 0)){
			res = res + (Math.abs(y)/l);
		}else if (y != 0){
			res = res + (Math.abs(y)/l)+1;
		}
		System.out.println(res);
	}
}
0