結果

問題 No.48 ロボットの操縦
ユーザー TwinkleStar74TwinkleStar74
提出日時 2017-09-18 17:33:55
言語 Java21
(openjdk 21)
結果
AC  
実行時間 52 ms / 5,000 ms
コード長 962 bytes
コンパイル時間 1,880 ms
コンパイル使用メモリ 77,948 KB
実行使用メモリ 50,400 KB
最終ジャッジ日時 2024-04-25 15:30:44
合計ジャッジ時間 3,960 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 50 ms
50,248 KB
testcase_01 AC 51 ms
49,936 KB
testcase_02 AC 50 ms
50,268 KB
testcase_03 AC 50 ms
50,284 KB
testcase_04 AC 52 ms
50,304 KB
testcase_05 AC 52 ms
50,252 KB
testcase_06 AC 52 ms
50,316 KB
testcase_07 AC 50 ms
50,300 KB
testcase_08 AC 50 ms
50,260 KB
testcase_09 AC 50 ms
49,924 KB
testcase_10 AC 50 ms
50,100 KB
testcase_11 AC 50 ms
50,344 KB
testcase_12 AC 49 ms
50,340 KB
testcase_13 AC 51 ms
50,244 KB
testcase_14 AC 49 ms
50,072 KB
testcase_15 AC 51 ms
50,324 KB
testcase_16 AC 50 ms
50,340 KB
testcase_17 AC 50 ms
50,260 KB
testcase_18 AC 50 ms
50,024 KB
testcase_19 AC 50 ms
50,308 KB
testcase_20 AC 51 ms
50,288 KB
testcase_21 AC 51 ms
50,068 KB
testcase_22 AC 51 ms
50,384 KB
testcase_23 AC 52 ms
50,360 KB
testcase_24 AC 51 ms
50,400 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class No48 {

	public static void main(String[] args) throws IOException, NumberFormatException{
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int touzai = Integer.parseInt(br.readLine());
		int nanboku = Integer.parseInt(br.readLine());
		int zenshin = Integer.parseInt(br.readLine());
		
		int x = Calculation.calc(touzai,zenshin);
		int y = Calculation.calc(nanboku,zenshin);
		
		System.out.println( x + y + Calculation.direction(touzai,nanboku));
	}
	
	
	public static class Calculation{
	
		public static int calc(int x, int y){
			if (Math.abs(x)%y == 0) return (Math.abs(x)/y); //Math.abs(x)はxの絶対値
			else return (Math.abs(x)/y) + 1;
		}
		
		public static int direction(int x, int y){
			if (x != 0 && y < 0 ) return 2;
			if (x != 0 && 0 <= y) return 1;
			if (x == 0 && y <0) return 2;
			else return 0;
		}
	}
}
0