結果

問題 No.48 ロボットの操縦
ユーザー TwinkleStar74TwinkleStar74
提出日時 2017-09-18 17:33:55
言語 Java21
(openjdk 21)
結果
AC  
実行時間 43 ms / 5,000 ms
コード長 962 bytes
コンパイル時間 1,963 ms
コンパイル使用メモリ 74,460 KB
実行使用メモリ 49,988 KB
最終ジャッジ日時 2023-08-07 21:09:47
合計ジャッジ時間 4,003 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
49,116 KB
testcase_01 AC 43 ms
49,276 KB
testcase_02 AC 43 ms
49,656 KB
testcase_03 AC 43 ms
49,248 KB
testcase_04 AC 42 ms
49,232 KB
testcase_05 AC 42 ms
49,536 KB
testcase_06 AC 43 ms
49,412 KB
testcase_07 AC 42 ms
49,988 KB
testcase_08 AC 42 ms
49,316 KB
testcase_09 AC 42 ms
49,336 KB
testcase_10 AC 43 ms
49,216 KB
testcase_11 AC 42 ms
49,620 KB
testcase_12 AC 43 ms
49,264 KB
testcase_13 AC 43 ms
49,192 KB
testcase_14 AC 43 ms
49,084 KB
testcase_15 AC 43 ms
49,412 KB
testcase_16 AC 43 ms
49,288 KB
testcase_17 AC 42 ms
49,308 KB
testcase_18 AC 43 ms
49,080 KB
testcase_19 AC 42 ms
49,320 KB
testcase_20 AC 42 ms
49,396 KB
testcase_21 AC 43 ms
49,660 KB
testcase_22 AC 43 ms
49,288 KB
testcase_23 AC 42 ms
49,652 KB
testcase_24 AC 43 ms
49,204 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