結果

問題 No.446 ゆきこーだーの雨と雪 (1)
ユーザー omuretsu2omuretsu2
提出日時 2017-05-24 14:58:30
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 1,258 bytes
コンパイル時間 2,256 ms
コンパイル使用メモリ 77,616 KB
実行使用メモリ 57,572 KB
最終ジャッジ日時 2023-10-19 19:59:32
合計ジャッジ時間 5,240 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 AC 125 ms
57,076 KB
testcase_02 RE -
testcase_03 AC 125 ms
57,124 KB
testcase_04 RE -
testcase_05 RE -
testcase_06 AC 125 ms
57,376 KB
testcase_07 WA -
testcase_08 AC 126 ms
57,296 KB
testcase_09 WA -
testcase_10 RE -
testcase_11 RE -
testcase_12 AC 126 ms
57,352 KB
testcase_13 AC 123 ms
57,112 KB
testcase_14 AC 113 ms
56,092 KB
testcase_15 AC 123 ms
57,368 KB
testcase_16 AC 125 ms
57,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.util.regex.Pattern;
import java.util.regex.Matcher;

class Sample {
	public static void main(String[] args){
		// スキャナーを定義
		Scanner scanner = new Scanner(System.in);
		// 入力値を文字列として取得
		String numberAStr = scanner.next();
		String numberBStr = scanner.next();
		// 正規表現を定義
		Pattern pattern = Pattern.compile("^[0-9a-zA-Z]*$");
		Matcher matcherA = pattern.matcher(numberAStr);
		Matcher matcherB = pattern.matcher(numberBStr);
		// 条件分岐
		if(!matcherA.matches() || !matcherB.matches()){
			System.out.println("NG");
		} else if (!matcherA.matches() && !matcherB.matches()) {
			System.out.println("NG");
		} else {
			if(numberAStr.indexOf("0")==1 || numberBStr.indexOf("0")==1){
				System.out.println("NG");
			} else if(numberAStr.indexOf("0")==1 && numberBStr.indexOf("0")==1){
				System.out.println("NG");
			} else {
				int numberAInt = Integer.parseInt(numberAStr);
				int numberBInt = Integer.parseInt(numberBStr);
				if(numberAInt > 12345 || numberBInt > 12345){
					System.out.println("NG");
				} else if (numberAInt > 12345 && numberBInt > 12345) {
					System.out.println("NG");
				} else {
					System.out.println("OK");
				}
			}
		}
	}
}

0