結果

問題 No.48 ロボットの操縦
ユーザー kazapyon27kazapyon27
提出日時 2017-05-13 10:30:52
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 990 bytes
コンパイル時間 6,205 ms
コンパイル使用メモリ 74,892 KB
実行使用メモリ 56,564 KB
最終ジャッジ日時 2023-10-13 16:14:51
合計ジャッジ時間 6,683 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 111 ms
55,736 KB
testcase_01 AC 111 ms
55,804 KB
testcase_02 AC 111 ms
55,248 KB
testcase_03 AC 119 ms
55,956 KB
testcase_04 AC 113 ms
55,688 KB
testcase_05 WA -
testcase_06 AC 116 ms
55,840 KB
testcase_07 AC 117 ms
55,476 KB
testcase_08 AC 112 ms
56,104 KB
testcase_09 AC 109 ms
55,828 KB
testcase_10 AC 105 ms
55,752 KB
testcase_11 AC 113 ms
56,064 KB
testcase_12 AC 107 ms
56,096 KB
testcase_13 AC 106 ms
55,868 KB
testcase_14 AC 106 ms
56,256 KB
testcase_15 AC 106 ms
56,016 KB
testcase_16 AC 105 ms
56,112 KB
testcase_17 AC 113 ms
56,028 KB
testcase_18 AC 107 ms
56,564 KB
testcase_19 AC 106 ms
55,908 KB
testcase_20 AC 110 ms
56,144 KB
testcase_21 AC 106 ms
55,720 KB
testcase_22 AC 105 ms
55,512 KB
testcase_23 AC 104 ms
54,132 KB
testcase_24 AC 105 ms
56,108 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){
				Order++;
				if(TargetX!=0)
					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