結果
| 問題 |
No.169 何分かかるの!?
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-05-30 18:44:04 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 56 ms / 1,000 ms |
| コード長 | 1,901 bytes |
| コンパイル時間 | 3,615 ms |
| コンパイル使用メモリ | 77,564 KB |
| 実行使用メモリ | 50,232 KB |
| 最終ジャッジ日時 | 2024-09-21 19:24:07 |
| 合計ジャッジ時間 | 6,144 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 22 |
ソースコード
package test_5;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/**
* コピーに時間がかかるので、しばらくして確認すると
* 「K%完了しました。あとS分かかります。」
* と表示されていました。
*
* 全体の処理時間(分)を計算してあげてください。
* 答えは、小数部分の切り捨てをし、整数部分のみを答えてください。
*/
public class Question_08_0530 {
static final int RATIO_MIN = 1;
static final int RATIO_MAX = 99;
static final int MINUTE_MIN = 1;
static final int MINUTE_MAX = 1000000;
public static void main(String[] args) {
InputStreamReader re = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(re);
try {
int raito = Integer.parseInt(br.readLine());
int minute = Integer.parseInt(br.readLine());
int fullTime;
if (NumJudg(raito, RATIO_MIN, RATIO_MAX) && NumJudg(minute, MINUTE_MIN, MINUTE_MAX)) {
fullTime = (int) (minute / ((100 - raito) * 0.01));
System.out.println(fullTime);
} else {
System.out.println("数値が有効範囲外です");
}
} catch (NumberFormatException e) {
System.out.println("数字を入力して下さい。");
} catch (IOException e) {
System.out.println("エラーが発生しました。");
} finally {
try {
re.close();
br.close();
} catch (IOException e) {
System.out.println("InputStreamReader、BufferedReaderクローズ中にエラーが発生しました");
}
}
}
/**
* 有効値判定
* @param num 判定する数字
* @param max 最大値
* @param min 最小値
* @return 範囲内ならtrue,範囲外ならfalseを返す
*/
private static boolean NumJudg(int num, int min, int max) {
Boolean result = false;
if (min <= num && num <= max) {
result = true;
}
return result;
}
}