結果

問題 No.48 ロボットの操縦
ユーザー shinwisteriashinwisteria
提出日時 2017-03-18 21:18:49
言語 Java21
(openjdk 21)
結果
AC  
実行時間 126 ms / 5,000 ms
コード長 594 bytes
コンパイル時間 3,727 ms
コンパイル使用メモリ 72,680 KB
実行使用メモリ 56,496 KB
最終ジャッジ日時 2023-09-18 02:51:48
合計ジャッジ時間 7,964 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
56,076 KB
testcase_01 AC 125 ms
56,204 KB
testcase_02 AC 123 ms
56,036 KB
testcase_03 AC 125 ms
56,496 KB
testcase_04 AC 124 ms
55,644 KB
testcase_05 AC 124 ms
55,884 KB
testcase_06 AC 124 ms
55,816 KB
testcase_07 AC 124 ms
56,004 KB
testcase_08 AC 124 ms
56,012 KB
testcase_09 AC 124 ms
55,908 KB
testcase_10 AC 126 ms
56,112 KB
testcase_11 AC 124 ms
55,396 KB
testcase_12 AC 124 ms
55,660 KB
testcase_13 AC 124 ms
55,872 KB
testcase_14 AC 125 ms
55,776 KB
testcase_15 AC 123 ms
55,960 KB
testcase_16 AC 123 ms
55,752 KB
testcase_17 AC 124 ms
55,500 KB
testcase_18 AC 124 ms
55,792 KB
testcase_19 AC 124 ms
55,812 KB
testcase_20 AC 124 ms
55,896 KB
testcase_21 AC 125 ms
55,476 KB
testcase_22 AC 123 ms
55,932 KB
testcase_23 AC 124 ms
55,892 KB
testcase_24 AC 124 ms
55,732 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Robo {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int X = s.nextInt(), Y = s.nextInt(), L = s.nextInt(), count = 0;
		s.close();
		if(Y >= 0){
				count += COUNT(Y, L);
				if(X != 0){
					count += COUNT(X,L) + 1;
				}
		}else{
			count += 2;
			if(X == 0){
				count += COUNT(Y,L);
			}else{
				count += COUNT(X,L);
				count += COUNT(Y,L);
			}
			
		}
		System.out.println(count);

	}
	
	static int COUNT(int p,int k){
		if(p%k == 0){
			return Math.abs(p/k);
		}else{
			return Math.abs(p/k) + 1;
		}
	}
}
0