結果

問題 No.48 ロボットの操縦
ユーザー AoiroFukurouAoiroFukurou
提出日時 2014-12-21 17:55:47
言語 Java21
(openjdk 21)
結果
AC  
実行時間 122 ms / 5,000 ms
コード長 525 bytes
コンパイル時間 2,930 ms
コンパイル使用メモリ 74,460 KB
実行使用メモリ 41,788 KB
最終ジャッジ日時 2024-05-01 13:32:36
合計ジャッジ時間 6,541 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 105 ms
41,340 KB
testcase_01 AC 109 ms
41,452 KB
testcase_02 AC 122 ms
41,324 KB
testcase_03 AC 104 ms
41,440 KB
testcase_04 AC 117 ms
41,372 KB
testcase_05 AC 100 ms
40,024 KB
testcase_06 AC 113 ms
41,464 KB
testcase_07 AC 106 ms
41,344 KB
testcase_08 AC 117 ms
41,460 KB
testcase_09 AC 113 ms
41,260 KB
testcase_10 AC 110 ms
41,728 KB
testcase_11 AC 116 ms
41,252 KB
testcase_12 AC 114 ms
41,416 KB
testcase_13 AC 114 ms
41,728 KB
testcase_14 AC 107 ms
41,596 KB
testcase_15 AC 114 ms
41,384 KB
testcase_16 AC 118 ms
41,256 KB
testcase_17 AC 114 ms
41,092 KB
testcase_18 AC 113 ms
41,380 KB
testcase_19 AC 115 ms
41,260 KB
testcase_20 AC 114 ms
41,376 KB
testcase_21 AC 109 ms
41,384 KB
testcase_22 AC 107 ms
41,472 KB
testcase_23 AC 117 ms
41,484 KB
testcase_24 AC 112 ms
41,788 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package benkyoukai;

import java.util.Scanner;


public class Robot {
public static void main(String[] args) {
	int x, y, l;
	int ans=0;
	Scanner sc = new Scanner(System.in);
	x = sc.nextInt();
	y = sc.nextInt();
	l = sc.nextInt();
	x=Math.abs(x);
	if(y==0){
		if(x==0){
			ans = 0;
		}else{
			ans = (x + l -1)/l+1;
		}
	
}
	if(y>0){
		ans = (y+l-1)/l;
		if(x!=0){
			ans +=1+(x+l-1)/l;
		}
			
		}
	if(y<0){
		ans = (-y+l-1)/l;
		if(x==0){
			ans +=2;
		}else{
			ans +=(2+(x+l-1)/l);
		}
	}
	System.out.println(ans);
	}
}
0