結果
| 問題 |
No.388 階段 (1)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-05-10 18:33:41 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 51 ms / 2,000 ms |
| コード長 | 1,879 bytes |
| コンパイル時間 | 3,163 ms |
| コンパイル使用メモリ | 74,392 KB |
| 実行使用メモリ | 36,896 KB |
| 最終ジャッジ日時 | 2024-09-15 07:10:53 |
| 合計ジャッジ時間 | 4,581 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 12 |
ソースコード
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クローズに失敗");
}
}
}
}