結果

問題 No.48 ロボットの操縦
ユーザー omi_UTomi_UT
提出日時 2017-03-10 21:34:48
言語 Java21
(openjdk 21)
結果
AC  
実行時間 127 ms / 5,000 ms
コード長 449 bytes
コンパイル時間 2,044 ms
コンパイル使用メモリ 71,584 KB
実行使用メモリ 56,260 KB
最終ジャッジ日時 2023-09-06 13:19:58
合計ジャッジ時間 6,367 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
55,960 KB
testcase_01 AC 123 ms
55,352 KB
testcase_02 AC 127 ms
55,724 KB
testcase_03 AC 121 ms
55,468 KB
testcase_04 AC 120 ms
55,520 KB
testcase_05 AC 121 ms
55,844 KB
testcase_06 AC 111 ms
55,952 KB
testcase_07 AC 113 ms
55,732 KB
testcase_08 AC 113 ms
55,808 KB
testcase_09 AC 107 ms
55,768 KB
testcase_10 AC 109 ms
56,036 KB
testcase_11 AC 113 ms
55,956 KB
testcase_12 AC 108 ms
55,916 KB
testcase_13 AC 110 ms
55,464 KB
testcase_14 AC 111 ms
55,724 KB
testcase_15 AC 113 ms
56,100 KB
testcase_16 AC 114 ms
56,260 KB
testcase_17 AC 111 ms
56,008 KB
testcase_18 AC 108 ms
55,648 KB
testcase_19 AC 108 ms
55,936 KB
testcase_20 AC 108 ms
55,968 KB
testcase_21 AC 121 ms
56,192 KB
testcase_22 AC 116 ms
55,356 KB
testcase_23 AC 108 ms
55,668 KB
testcase_24 AC 105 ms
54,640 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.IOException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args)throws IOException {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		int l = sc.nextInt();

		int ans = Math.abs(x/l) + Math.abs(y/l) + 1;
		if (x % l != 0) ans += 1;
		if (y % l != 0) ans += 1;

		if (y < 0){
			ans += 1;
		}else if (x == 0){
			ans -= 1;
		}

		System.out.println(ans);
	}
}
0