結果

問題 No.48 ロボットの操縦
ユーザー enuo-9enuo-9
提出日時 2016-09-15 15:33:23
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 655 bytes
コンパイル時間 3,435 ms
コンパイル使用メモリ 74,616 KB
実行使用メモリ 54,180 KB
最終ジャッジ日時 2024-04-28 13:50:13
合計ジャッジ時間 7,758 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 112 ms
41,584 KB
testcase_01 AC 111 ms
41,112 KB
testcase_02 AC 112 ms
41,000 KB
testcase_03 AC 1,487 ms
40,348 KB
testcase_04 AC 111 ms
41,000 KB
testcase_05 AC 115 ms
41,312 KB
testcase_06 WA -
testcase_07 AC 113 ms
41,352 KB
testcase_08 AC 122 ms
41,540 KB
testcase_09 AC 113 ms
41,472 KB
testcase_10 AC 107 ms
40,900 KB
testcase_11 AC 112 ms
41,164 KB
testcase_12 AC 112 ms
41,684 KB
testcase_13 AC 102 ms
40,084 KB
testcase_14 AC 113 ms
41,632 KB
testcase_15 AC 114 ms
41,484 KB
testcase_16 AC 101 ms
40,284 KB
testcase_17 AC 117 ms
41,360 KB
testcase_18 AC 106 ms
40,184 KB
testcase_19 AC 110 ms
40,976 KB
testcase_20 AC 99 ms
40,212 KB
testcase_21 AC 112 ms
41,700 KB
testcase_22 AC 111 ms
41,572 KB
testcase_23 AC 111 ms
41,380 KB
testcase_24 AC 108 ms
41,392 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(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