結果

問題 No.46 はじめのn歩
ユーザー nihi9119nihi9119
提出日時 2017-05-10 17:42:20
言語 Java21
(openjdk 21)
結果
AC  
実行時間 128 ms / 5,000 ms
コード長 1,042 bytes
コンパイル時間 5,817 ms
コンパイル使用メモリ 73,052 KB
実行使用メモリ 56,028 KB
最終ジャッジ日時 2023-10-13 10:04:50
合計ジャッジ時間 5,414 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 128 ms
55,588 KB
testcase_01 AC 126 ms
55,656 KB
testcase_02 AC 123 ms
55,860 KB
testcase_03 AC 123 ms
54,084 KB
testcase_04 AC 124 ms
55,856 KB
testcase_05 AC 121 ms
55,860 KB
testcase_06 AC 124 ms
55,748 KB
testcase_07 AC 124 ms
55,844 KB
testcase_08 AC 123 ms
56,028 KB
testcase_09 AC 123 ms
55,768 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.InputMismatchException;
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 (InputMismatchException  e) {
			System.out.println("数値または、10の9乗=1000000000の範囲内で入力して下さい。");
		} finally {
			sc.close();
		}
	}
}
0