結果

問題 No.48 ロボットの操縦
ユーザー dogwood0424dogwood0424
提出日時 2017-12-01 12:42:54
言語 Java21
(openjdk 21)
結果
AC  
実行時間 1,062 ms / 5,000 ms
コード長 711 bytes
コンパイル時間 3,643 ms
コンパイル使用メモリ 73,916 KB
実行使用メモリ 56,308 KB
最終ジャッジ日時 2023-08-18 15:15:52
合計ジャッジ時間 8,497 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 118 ms
56,084 KB
testcase_01 AC 121 ms
56,308 KB
testcase_02 AC 119 ms
56,308 KB
testcase_03 AC 1,062 ms
56,056 KB
testcase_04 AC 118 ms
55,980 KB
testcase_05 AC 119 ms
55,876 KB
testcase_06 AC 118 ms
55,832 KB
testcase_07 AC 121 ms
55,872 KB
testcase_08 AC 123 ms
55,732 KB
testcase_09 AC 122 ms
55,544 KB
testcase_10 AC 120 ms
55,996 KB
testcase_11 AC 121 ms
55,988 KB
testcase_12 AC 124 ms
55,828 KB
testcase_13 AC 120 ms
56,084 KB
testcase_14 AC 120 ms
55,520 KB
testcase_15 AC 124 ms
56,140 KB
testcase_16 AC 119 ms
55,972 KB
testcase_17 AC 120 ms
56,064 KB
testcase_18 AC 121 ms
56,060 KB
testcase_19 AC 120 ms
54,076 KB
testcase_20 AC 119 ms
55,712 KB
testcase_21 AC 119 ms
56,088 KB
testcase_22 AC 119 ms
55,720 KB
testcase_23 AC 120 ms
56,084 KB
testcase_24 AC 120 ms
56,180 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class No48 {
	public static void main(String[]args) {
		Scanner sc =new Scanner(System.in);

		int X,Y,L,cnt;
		X = sc.nextInt();
		Y = sc.nextInt();
		L = sc.nextInt();
		cnt=0;

		if(Y>=0) {
			while(Y>0) {
				Y=Y-L;
				cnt++;
			}
			if(X>0) {
				cnt++;
				while(X>0) {
					X=X-L;
					cnt++;
				}
			}
			else if(X<0){
				cnt++;
				X=(-1)*X;
				while(X>0) {
					X=X-L;
					cnt++;
				}
			}
		}
		else {
			Y=(-1)*Y;
			while(Y>0) {
			Y=Y-L;
			cnt++;
		}
			if(X>0) {
				cnt+=2;
				while(X>0) {
					X=X-L;
					cnt++;
				}
			}
			else {
				cnt+=2;
				X=(-1)*X;
				while(X>0) {
					X=X-L;
					cnt++;
				}
			}
		}

		System.out.println(cnt);


	}

}
0