結果

問題 No.48 ロボットの操縦
ユーザー kuramubonnkuramubonn
提出日時 2023-02-02 09:48:18
言語 Java21
(openjdk 21)
結果
AC  
実行時間 129 ms / 5,000 ms
コード長 784 bytes
コンパイル時間 1,972 ms
コンパイル使用メモリ 71,572 KB
実行使用メモリ 56,432 KB
最終ジャッジ日時 2023-09-14 17:10:27
合計ジャッジ時間 6,502 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
55,952 KB
testcase_01 AC 124 ms
55,432 KB
testcase_02 AC 124 ms
55,428 KB
testcase_03 AC 125 ms
53,796 KB
testcase_04 AC 125 ms
55,980 KB
testcase_05 AC 126 ms
55,820 KB
testcase_06 AC 125 ms
55,996 KB
testcase_07 AC 123 ms
55,996 KB
testcase_08 AC 127 ms
55,580 KB
testcase_09 AC 129 ms
55,744 KB
testcase_10 AC 125 ms
55,736 KB
testcase_11 AC 125 ms
55,472 KB
testcase_12 AC 126 ms
55,712 KB
testcase_13 AC 126 ms
55,876 KB
testcase_14 AC 125 ms
55,752 KB
testcase_15 AC 126 ms
55,908 KB
testcase_16 AC 125 ms
55,616 KB
testcase_17 AC 123 ms
56,044 KB
testcase_18 AC 125 ms
55,720 KB
testcase_19 AC 123 ms
55,632 KB
testcase_20 AC 124 ms
55,320 KB
testcase_21 AC 125 ms
55,716 KB
testcase_22 AC 126 ms
55,832 KB
testcase_23 AC 127 ms
55,560 KB
testcase_24 AC 122 ms
56,432 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt() , y=sc.nextInt() , l = sc.nextInt() , count = 0, muki = 0;
		//北
		if(y > 0) {
			count += y / l;
			if(y % l != 0)count++;//端数!
		}
		//東(右)
		if(x > 0) {
			count++;//向き変える(右向く)
			count += x / l;
			if(x % l != 0)count++;//端数!
			muki = 1;
		}else if(x < 0) {//西(左)
			count++;//向き変える(右向く)
			count += (x * -1) / l;
			if((x * -1) % l != 0)count++;//端数!
			muki = 1;
		}
		//南
		if(y < 0) {
			if(muki == 0)count++;//北を向いていたら2回方向転換
			count++;
			count += (y * -1) / l;
			if((y * -1) % l != 0)count++;//端数!
		}
		System.out.println(count);
	}
}
0