結果

問題 No.48 ロボットの操縦
ユーザー oyafusooyafuso
提出日時 2019-03-15 17:54:48
言語 Java21
(openjdk 21)
結果
AC  
実行時間 132 ms / 5,000 ms
コード長 882 bytes
コンパイル時間 2,307 ms
コンパイル使用メモリ 71,592 KB
実行使用メモリ 55,988 KB
最終ジャッジ日時 2023-09-14 12:37:54
合計ジャッジ時間 6,404 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
55,744 KB
testcase_01 AC 125 ms
55,548 KB
testcase_02 AC 125 ms
55,560 KB
testcase_03 AC 124 ms
55,820 KB
testcase_04 AC 123 ms
55,776 KB
testcase_05 AC 126 ms
55,724 KB
testcase_06 AC 132 ms
55,728 KB
testcase_07 AC 126 ms
55,848 KB
testcase_08 AC 124 ms
55,836 KB
testcase_09 AC 125 ms
55,724 KB
testcase_10 AC 123 ms
55,348 KB
testcase_11 AC 124 ms
54,204 KB
testcase_12 AC 123 ms
55,664 KB
testcase_13 AC 122 ms
55,720 KB
testcase_14 AC 123 ms
55,844 KB
testcase_15 AC 120 ms
55,912 KB
testcase_16 AC 123 ms
55,816 KB
testcase_17 AC 121 ms
55,596 KB
testcase_18 AC 121 ms
55,776 KB
testcase_19 AC 123 ms
55,988 KB
testcase_20 AC 123 ms
55,608 KB
testcase_21 AC 121 ms
55,588 KB
testcase_22 AC 124 ms
55,760 KB
testcase_23 AC 124 ms
55,580 KB
testcase_24 AC 123 ms
55,860 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

class Main {

	private static final String SPLIT_STR = " ";

	public static void main(String[] args) {
		// Scanner生成
		Scanner sc = new Scanner(System.in);
		// 入力設定
		String input = sc.nextLine();
		int X = Integer.parseInt(input);
		sc.reset();
		input = sc.nextLine();
		int Y = Integer.parseInt(input);
		sc.reset();
		input = sc.nextLine();
		int L = Integer.parseInt(input);
		// Scannerクローズ
		sc.close();

		/* メイン処理開始 */
		// 変数初期化
		int result = 0;
		int turnCnt = 0;
		// 結果設定
		if (X != 0) {
			turnCnt++;
		}
		if (X == 0 && Y < 0) {
			turnCnt++;
		}
		if (X < 0) {
			X *= -1;
		}
		if (Y < 0) {
			Y *= -1;
			turnCnt++;
		}
		result = (int)Math.ceil((double)X / L) + (int)Math.ceil((double)Y / L) + turnCnt;
		/* メイン処理終了 */

		// 結果出力
		System.out.println(result);
	}
}
0