結果

問題 No.446 ゆきこーだーの雨と雪 (1)
ユーザー omuretsu2
提出日時 2017-05-24 14:58:30
言語 Java
(openjdk 23)
結果
RE  
実行時間 -
コード長 1,258 bytes
コンパイル時間 2,041 ms
コンパイル使用メモリ 78,052 KB
実行使用メモリ 54,280 KB
最終ジャッジ日時 2024-09-19 16:07:44
合計ジャッジ時間 4,649 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 RE * 2
other AC * 7 WA * 2 RE * 4
権限があれば一括ダウンロードができます

ソースコード

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