結果

問題 No.446 ゆきこーだーの雨と雪 (1)
ユーザー yagi2yagi2
提出日時 2017-04-15 19:11:00
言語 Java21
(openjdk 21)
結果
AC  
実行時間 121 ms / 2,000 ms
コード長 1,188 bytes
コンパイル時間 2,061 ms
コンパイル使用メモリ 71,588 KB
実行使用メモリ 56,112 KB
最終ジャッジ日時 2023-09-25 22:21:23
合計ジャッジ時間 5,028 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 116 ms
55,540 KB
testcase_01 AC 119 ms
55,592 KB
testcase_02 AC 116 ms
55,812 KB
testcase_03 AC 116 ms
56,004 KB
testcase_04 AC 115 ms
55,552 KB
testcase_05 AC 116 ms
55,960 KB
testcase_06 AC 115 ms
56,112 KB
testcase_07 AC 116 ms
55,296 KB
testcase_08 AC 118 ms
55,604 KB
testcase_09 AC 117 ms
55,548 KB
testcase_10 AC 118 ms
55,836 KB
testcase_11 AC 119 ms
55,724 KB
testcase_12 AC 117 ms
55,800 KB
testcase_13 AC 117 ms
55,620 KB
testcase_14 AC 118 ms
55,876 KB
testcase_15 AC 121 ms
55,464 KB
testcase_16 AC 120 ms
55,432 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String A = sc.next();
        String B = sc.next();

        if (checkFormat(A) && checkFormat(B)) {
            if (checkRange(A) && checkRange(B)) {
                System.out.println("OK");
            } else {
                System.out.println("NG");
            }
        } else {
            System.out.println("NG");
        }

    }
    private static boolean checkFormat(String str) {
        boolean result = true;

        for (int i = 0; i < str.length(); i++) {
            if (!Character.isDigit(str.charAt(i))) {
                result = false;
                break;
            }

            if (i == 0 && str.charAt(i) == '0' && str.length() > 1) {
                result = false;
                break;
            }
        }

        return result;
    }

    private static boolean checkRange(String str) {
        boolean result = true;

        int num = Integer.parseInt(str);
        
        if (num < 0 || num > 12345) {
            result = false;
            
        }
        
        return result;
    }
}
0