結果

問題 No.48 ロボットの操縦
ユーザー kazapyon27kazapyon27
提出日時 2017-05-13 10:36:53
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 991 bytes
コンパイル時間 2,862 ms
コンパイル使用メモリ 74,256 KB
実行使用メモリ 56,668 KB
最終ジャッジ日時 2023-10-13 16:15:00
合計ジャッジ時間 6,609 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 108 ms
55,928 KB
testcase_01 AC 110 ms
56,124 KB
testcase_02 WA -
testcase_03 AC 107 ms
56,040 KB
testcase_04 AC 106 ms
56,136 KB
testcase_05 AC 108 ms
55,528 KB
testcase_06 AC 109 ms
55,792 KB
testcase_07 AC 107 ms
55,748 KB
testcase_08 AC 108 ms
55,908 KB
testcase_09 AC 107 ms
55,960 KB
testcase_10 AC 108 ms
55,856 KB
testcase_11 AC 110 ms
55,812 KB
testcase_12 AC 106 ms
55,596 KB
testcase_13 AC 111 ms
55,748 KB
testcase_14 AC 107 ms
55,748 KB
testcase_15 AC 108 ms
55,756 KB
testcase_16 AC 106 ms
56,360 KB
testcase_17 AC 108 ms
55,844 KB
testcase_18 AC 106 ms
55,696 KB
testcase_19 AC 108 ms
55,744 KB
testcase_20 AC 111 ms
56,036 KB
testcase_21 AC 107 ms
56,036 KB
testcase_22 AC 108 ms
55,888 KB
testcase_23 AC 108 ms
55,816 KB
testcase_24 AC 109 ms
56,668 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/*No.48 ロボットの操縦*/
import java.util.*;
public class No48 {
	static int Order=0;
	static int walk(int TargetPoint,int WalkSpec){
		int work=Math.abs(TargetPoint);
		if(TargetPoint%WalkSpec==0){
			Order+=work/WalkSpec;
			return TargetPoint/WalkSpec;
		}else{
			work/=WalkSpec;
			Order+=work+1;
			return work*WalkSpec+Math.abs(TargetPoint%WalkSpec);	
		}
	}
	public static void main(String[] args) {
		int TargetX,TargetY,WalkSpec,CurrentX=0,CurrentY=0;
		try(Scanner input = new Scanner((System.in))){
			TargetX=input.nextInt();
			TargetY=input.nextInt();
			WalkSpec=input.nextInt();
			if(TargetY<=0){
				if(TargetX!=0)
					Order++;
					CurrentX=walk(TargetX,WalkSpec);
				if(TargetY!=0){
					Order++;
					CurrentY=walk(TargetY,WalkSpec);					
				}
			}else{
				CurrentY=walk(TargetY,WalkSpec);
				if(TargetX!=0){
					Order++;
					CurrentX=walk(TargetX,WalkSpec);
				}
			}
			System.out.println(Order);
		}catch(Exception e){
			e.printStackTrace();
		}
	}
}
0