結果

問題 No.48 ロボットの操縦
ユーザー SuunnSuunn
提出日時 2018-11-20 05:36:29
言語 Java21
(openjdk 21)
結果
AC  
実行時間 107 ms / 5,000 ms
コード長 525 bytes
コンパイル時間 1,900 ms
コンパイル使用メモリ 71,876 KB
実行使用メモリ 56,668 KB
最終ジャッジ日時 2023-08-26 02:11:12
合計ジャッジ時間 5,370 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 106 ms
56,212 KB
testcase_01 AC 105 ms
56,068 KB
testcase_02 AC 104 ms
56,116 KB
testcase_03 AC 106 ms
56,092 KB
testcase_04 AC 104 ms
55,612 KB
testcase_05 AC 105 ms
56,268 KB
testcase_06 AC 103 ms
56,312 KB
testcase_07 AC 104 ms
56,668 KB
testcase_08 AC 107 ms
56,352 KB
testcase_09 AC 105 ms
56,424 KB
testcase_10 AC 107 ms
56,088 KB
testcase_11 AC 105 ms
55,948 KB
testcase_12 AC 104 ms
56,172 KB
testcase_13 AC 105 ms
55,576 KB
testcase_14 AC 106 ms
56,000 KB
testcase_15 AC 103 ms
56,080 KB
testcase_16 AC 104 ms
55,812 KB
testcase_17 AC 102 ms
56,140 KB
testcase_18 AC 103 ms
56,128 KB
testcase_19 AC 104 ms
56,120 KB
testcase_20 AC 103 ms
56,032 KB
testcase_21 AC 103 ms
55,992 KB
testcase_22 AC 102 ms
55,748 KB
testcase_23 AC 106 ms
55,780 KB
testcase_24 AC 106 ms
56,160 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
	

public class Main{
	
	
	public static void main(String args[])throws Exception{
		
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int Y = sc.nextInt();
		int L = sc.nextInt();
		X = Math.abs(X);
		int ans = 0;
		if(Y>0){
			ans += (Y-1)/L+1;
			if(X>0){
				ans += (X-1)/L+2;
			}
		}else if(Y<0){
			ans += 2;
			Y = Math.abs(Y);
			if(X>0){
				ans += (X-1)/L+1;
			}
			ans += (Y-1)/L+1;
		}else{
			if(X>0){
				ans += (X-1)/L+2;
			}
		}
		System.out.println(ans);
		
	}
}
0