結果

問題 No.48 ロボットの操縦
ユーザー enuo-9enuo-9
提出日時 2016-09-15 15:49:34
言語 Java21
(openjdk 21)
結果
AC  
実行時間 1,061 ms / 5,000 ms
コード長 693 bytes
コンパイル時間 3,088 ms
コンパイル使用メモリ 72,268 KB
実行使用メモリ 57,756 KB
最終ジャッジ日時 2023-08-14 00:57:30
合計ジャッジ時間 8,230 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
55,760 KB
testcase_01 AC 122 ms
55,852 KB
testcase_02 AC 122 ms
57,756 KB
testcase_03 AC 1,061 ms
55,800 KB
testcase_04 AC 119 ms
55,924 KB
testcase_05 AC 119 ms
55,920 KB
testcase_06 AC 122 ms
56,120 KB
testcase_07 AC 125 ms
55,984 KB
testcase_08 AC 125 ms
55,768 KB
testcase_09 AC 124 ms
56,504 KB
testcase_10 AC 121 ms
55,660 KB
testcase_11 AC 124 ms
56,088 KB
testcase_12 AC 130 ms
55,668 KB
testcase_13 AC 122 ms
56,708 KB
testcase_14 AC 121 ms
55,580 KB
testcase_15 AC 123 ms
56,220 KB
testcase_16 AC 121 ms
55,668 KB
testcase_17 AC 122 ms
56,124 KB
testcase_18 AC 124 ms
56,464 KB
testcase_19 AC 120 ms
55,848 KB
testcase_20 AC 121 ms
55,908 KB
testcase_21 AC 121 ms
56,292 KB
testcase_22 AC 119 ms
56,036 KB
testcase_23 AC 119 ms
55,424 KB
testcase_24 AC 122 ms
55,748 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class No048 {
	public static void main(String args[]){
		int x = 0;
		int y = 0;
		int distance = 0;
		int go = 0;
		int turn = 0;
		Scanner sc = new Scanner(System.in);

		x = sc.nextInt();
		y = sc.nextInt();
		go = sc.nextInt();

		//回頭に要する行為判定
		if(0<y && x==0){
			turn = 0;
		}else if(y==0 && x<0){
			turn = 1;
		}else if(0<y){
			turn = 1;

		}else if(y<0){
			turn = 2;
			y=y*-1;
			}


		if(y!=0){
			while(true){
				y=y-go;
				turn++;
				if(y<=0){
					break;
				}
			}
		}

		if(x<0){x=x*-1;}

		if(x!=0){
			while(true){
				x=x-go;
				turn++;
				if(x<=0){
					break;
				}
			}
		}


		System.out.println(turn);
	}
}
0