結果

問題 No.48 ロボットの操縦
ユーザー enuo-9enuo-9
提出日時 2016-09-15 15:49:34
言語 Java21
(openjdk 21)
結果
AC  
実行時間 1,551 ms / 5,000 ms
コード長 693 bytes
コンパイル時間 2,875 ms
コンパイル使用メモリ 74,272 KB
実行使用メモリ 41,840 KB
最終ジャッジ日時 2024-05-01 14:07:01
合計ジャッジ時間 7,943 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 113 ms
41,600 KB
testcase_01 AC 101 ms
41,456 KB
testcase_02 AC 117 ms
41,628 KB
testcase_03 AC 1,551 ms
40,968 KB
testcase_04 AC 104 ms
41,392 KB
testcase_05 AC 102 ms
41,472 KB
testcase_06 AC 105 ms
41,056 KB
testcase_07 AC 126 ms
41,512 KB
testcase_08 AC 125 ms
41,484 KB
testcase_09 AC 119 ms
41,172 KB
testcase_10 AC 117 ms
41,344 KB
testcase_11 AC 113 ms
41,840 KB
testcase_12 AC 115 ms
41,572 KB
testcase_13 AC 111 ms
41,152 KB
testcase_14 AC 121 ms
41,404 KB
testcase_15 AC 119 ms
41,660 KB
testcase_16 AC 115 ms
41,780 KB
testcase_17 AC 109 ms
41,248 KB
testcase_18 AC 114 ms
41,580 KB
testcase_19 AC 117 ms
41,528 KB
testcase_20 AC 106 ms
41,772 KB
testcase_21 AC 105 ms
41,584 KB
testcase_22 AC 106 ms
41,412 KB
testcase_23 AC 102 ms
41,240 KB
testcase_24 AC 115 ms
41,612 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