結果

問題 No.46 はじめのn歩
ユーザー nihi9119nihi9119
提出日時 2017-05-10 17:20:16
言語 Java21
(openjdk 21)
結果
AC  
実行時間 125 ms / 5,000 ms
コード長 1,011 bytes
コンパイル時間 3,455 ms
コンパイル使用メモリ 72,164 KB
実行使用メモリ 56,048 KB
最終ジャッジ日時 2023-10-13 10:04:34
合計ジャッジ時間 5,314 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
56,000 KB
testcase_01 AC 120 ms
55,448 KB
testcase_02 AC 122 ms
56,048 KB
testcase_03 AC 123 ms
55,672 KB
testcase_04 AC 125 ms
55,516 KB
testcase_05 AC 122 ms
55,612 KB
testcase_06 AC 122 ms
55,700 KB
testcase_07 AC 122 ms
55,592 KB
testcase_08 AC 124 ms
55,484 KB
testcase_09 AC 124 ms
55,608 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Question_01_0509_3 {
	public static void main(String[] args) {

		// 有効範囲
		final int MIN = 0;
		final int MAX = (int) Math.pow(10, 9);
		Scanner sc = new Scanner(System.in);
		long strideLength = 0; // 歩幅
		long distance = 0; // 距離
		long mStepCount; // 最小の歩数(minimum)

		try {
			strideLength = sc.nextLong();
			distance = sc.nextLong();

			// a b ともに正の整数。(1≤a,b≤10の9乗=1000000000)
			if (strideLength > MIN && distance > MIN && distance <= MAX && distance <= MAX) {
				mStepCount = distance / strideLength;
				if (distance % strideLength != 0) {
					mStepCount += 1;
				}
				System.out.println(mStepCount);
			} else {
				System.out.println("1≤a,b≤10の9乗=1000000000の範囲内で入力して下さい。");
			}
		} catch (java.util.InputMismatchException e) {
			System.out.println("数値または、10の9乗=1000000000の範囲内で入力して下さい。");
		} finally {
			sc.close();
		}
	}
}
0