結果
| 問題 |
No.207 世界のなんとか
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-06-26 08:43:46 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 53 ms / 5,000 ms |
| コード長 | 2,050 bytes |
| コンパイル時間 | 4,427 ms |
| コンパイル使用メモリ | 86,084 KB |
| 実行使用メモリ | 37,276 KB |
| 最終ジャッジ日時 | 2024-07-03 22:06:54 |
| 合計ジャッジ時間 | 6,058 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 19 |
ソースコード
import static java.lang.System.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
public class worldNabeatsu_2 {
static final int FIRST_MIN = 1;
static final int SECOND_MIN = 1;
static final int DIFF_MIN = 0;
static final int FIRST_MAX = 2000000000;
static final int SECOND_MAX = 2000000000;
static final int DIFF_MAX = 100;
public static void main(String[] args) {
InputStreamReader re = new InputStreamReader(System.in);
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
ArrayList<Integer> answerList = new ArrayList<Integer>();
try{
String[] inputs = reader.readLine().split(" ");
int firstNum = Integer.parseInt(inputs[0]);
int secondNum = Integer.parseInt(inputs[1]);
int diff = secondNum - firstNum;
if(numJudge(firstNum, FIRST_MIN, FIRST_MAX)
&&numJudge(secondNum, SECOND_MIN, SECOND_MAX)
&&numJudge(diff, DIFF_MIN, DIFF_MAX)){
for(int i = firstNum; i <= secondNum; i++){
if(threeJudge(i)){
answerList.add(i);
}else if(i % 3 == 0){
answerList.add(i);
}
}
for(int display : answerList){
System.out.println(display);
}
}else{
System.out.println("入力された数値が有効な値ではありません。");
}
}catch(NumberFormatException ne){
System.out.println("数字を入力してください");
}catch(IOException ie){
System.out.println("読み込み時にエラーが発生しました。");
}finally{
try{
reader.close();
re.close();
}catch(IOException ie){
System.out.println("InputStreamReaderかBufferedReaderのクローズに失敗しました。");
}
}
}
static boolean numJudge(int input, int min, int max){
boolean result = false;
if(input >= min && input <= max){
result = true;
}
return result;
}
static boolean threeJudge(int targetNum){
boolean result = false;
String str = String.valueOf(targetNum);
if(str.contains("3")){
result = true;
}
return result;
}
}