結果

問題 No.48 ロボットの操縦
ユーザー koukonkokoukonko
提出日時 2015-12-07 17:00:04
言語 Java21
(openjdk 21)
結果
AC  
実行時間 44 ms / 5,000 ms
コード長 793 bytes
コンパイル時間 1,979 ms
コンパイル使用メモリ 71,392 KB
実行使用メモリ 49,560 KB
最終ジャッジ日時 2023-08-14 00:19:06
合計ジャッジ時間 4,030 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
49,288 KB
testcase_01 AC 42 ms
49,520 KB
testcase_02 AC 42 ms
49,556 KB
testcase_03 AC 42 ms
49,224 KB
testcase_04 AC 42 ms
49,408 KB
testcase_05 AC 42 ms
49,252 KB
testcase_06 AC 42 ms
49,340 KB
testcase_07 AC 42 ms
49,292 KB
testcase_08 AC 42 ms
49,292 KB
testcase_09 AC 42 ms
49,336 KB
testcase_10 AC 43 ms
49,208 KB
testcase_11 AC 44 ms
49,220 KB
testcase_12 AC 42 ms
49,200 KB
testcase_13 AC 42 ms
49,452 KB
testcase_14 AC 42 ms
49,328 KB
testcase_15 AC 42 ms
49,228 KB
testcase_16 AC 41 ms
49,220 KB
testcase_17 AC 42 ms
49,452 KB
testcase_18 AC 42 ms
49,348 KB
testcase_19 AC 41 ms
49,560 KB
testcase_20 AC 42 ms
49,272 KB
testcase_21 AC 44 ms
49,540 KB
testcase_22 AC 42 ms
49,288 KB
testcase_23 AC 43 ms
49,236 KB
testcase_24 AC 42 ms
49,132 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Main {
	public static void main(String[] args) {
		BufferedReader buff = new BufferedReader(new InputStreamReader(System.in));

		try {
			int X = Integer.parseInt(buff.readLine());
			int Y = Integer.parseInt(buff.readLine());
			int L = Integer.parseInt(buff.readLine());

			int ans = 0;
			if(Y > 0){
				if(X != 0){
					++ans;
				}
			}else if(Y < 0){
				ans += 2;
			}else if(X != 0){
				++ans;
			}

			if(X < 0){
				X *= -1;
			}
			if(Y < 0){
				Y *= -1;
			}

			ans += X / L;
			if(X % L > 0){
				ans++;
			}
			ans += Y / L;
			if(Y % L > 0){
				ans++;
			}

			System.out.println(ans);

		} catch (NumberFormatException e) {

		} catch (IOException e) {

		}
	}
}
0