結果

問題 No.388 階段 (1)
ユーザー nihi9119nihi9119
提出日時 2017-05-10 18:33:41
言語 Java21
(openjdk 21)
結果
AC  
実行時間 46 ms / 2,000 ms
コード長 1,879 bytes
コンパイル時間 3,113 ms
コンパイル使用メモリ 71,452 KB
実行使用メモリ 49,864 KB
最終ジャッジ日時 2023-10-13 10:04:55
合計ジャッジ時間 4,702 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
49,864 KB
testcase_01 AC 44 ms
49,524 KB
testcase_02 AC 43 ms
49,104 KB
testcase_03 AC 44 ms
49,520 KB
testcase_04 AC 46 ms
49,060 KB
testcase_05 AC 44 ms
48,968 KB
testcase_06 AC 44 ms
49,284 KB
testcase_07 AC 44 ms
49,444 KB
testcase_08 AC 44 ms
49,348 KB
testcase_09 AC 43 ms
49,060 KB
testcase_10 AC 44 ms
49,240 KB
testcase_11 AC 44 ms
49,344 KB
testcase_12 AC 43 ms
49,208 KB
testcase_13 AC 44 ms
48,972 KB
testcase_14 AC 43 ms
49,360 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

/* No.388 階段 (1)
 * ステア君は階段を上るのが大好きです。今日も近所にあるお寺のお気に入りの階段を上っています。
 *  SS 段目に上がったとき、ふとステア君は自分の家でいうと何階に相当する高さに居るのかが気になりました。
 *  ステア君の家の一階層分に相当する段数 FF が与えられるので、ステア君が今何階にいるのか計算して下さい。
 *
 * */

public class Question_02_0510_3 {

	//有効範囲
	static final int NOWSTAGE_MIN = 0;
	static final int NOWSTAGE_MAX = 456;
	static final int ONE_STAGE_WIDTH_MIN = 1;
	static final int ONE_STAGE_WIDTH_MAX = 123;

	public static void main(String[] args) {
		InputStreamReader re = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(re);
		int nowStage = 0; // 現在居る段数
		int oneStageWidth = 0; // ステア君の家の一階層分に相当する段数

		try {
			String[] inputString = br.readLine().split(" ");
			nowStage = Integer.parseInt(inputString[0]);
			oneStageWidth = Integer.parseInt(inputString[1]);

			if (nowStage >= NOWSTAGE_MIN && nowStage <= NOWSTAGE_MAX
					&& oneStageWidth >= ONE_STAGE_WIDTH_MIN && oneStageWidth <= ONE_STAGE_WIDTH_MAX) {
				System.out.println((nowStage / oneStageWidth) + 1);
			} else {
				System.out.println("制約違反です。 0≤現在居る段数≤456 ,1≤段数≤123");
			}
		} catch (NumberFormatException e) {
			System.out.println("数値または、整数の範囲内で入力して下さい。");
		} catch (IOException e) {
			System.out.println("エラーです");
		} finally {
			try {
				br.close();
			} catch (IOException e) {
				System.out.println("BufferedReaderクローズに失敗");
			}
		}
	}

}
0