結果

問題 No.48 ロボットの操縦
ユーザー kou6839kou6839
提出日時 2014-11-19 13:30:44
言語 Java21
(openjdk 21)
結果
AC  
実行時間 146 ms / 5,000 ms
コード長 533 bytes
コンパイル時間 2,436 ms
コンパイル使用メモリ 74,224 KB
実行使用メモリ 41,704 KB
最終ジャッジ日時 2024-05-01 13:27:49
合計ジャッジ時間 6,337 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
40,404 KB
testcase_01 AC 145 ms
41,464 KB
testcase_02 AC 140 ms
41,516 KB
testcase_03 AC 139 ms
41,448 KB
testcase_04 AC 139 ms
41,576 KB
testcase_05 AC 127 ms
40,892 KB
testcase_06 AC 131 ms
41,008 KB
testcase_07 AC 125 ms
40,604 KB
testcase_08 AC 134 ms
41,604 KB
testcase_09 AC 135 ms
41,328 KB
testcase_10 AC 123 ms
40,688 KB
testcase_11 AC 139 ms
41,424 KB
testcase_12 AC 141 ms
41,540 KB
testcase_13 AC 143 ms
41,572 KB
testcase_14 AC 140 ms
41,704 KB
testcase_15 AC 138 ms
41,556 KB
testcase_16 AC 138 ms
41,412 KB
testcase_17 AC 124 ms
40,336 KB
testcase_18 AC 146 ms
41,616 KB
testcase_19 AC 139 ms
41,504 KB
testcase_20 AC 142 ms
41,640 KB
testcase_21 AC 142 ms
41,380 KB
testcase_22 AC 139 ms
41,472 KB
testcase_23 AC 133 ms
40,468 KB
testcase_24 AC 128 ms
40,904 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
 

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