結果

問題 No.446 ゆきこーだーの雨と雪 (1)
ユーザー Tsukasa_TypeTsukasa_Type
提出日時 2018-02-11 01:17:53
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 960 bytes
コンパイル時間 1,883 ms
コンパイル使用メモリ 74,488 KB
実行使用メモリ 41,356 KB
最終ジャッジ日時 2024-04-24 12:50:15
合計ジャッジ時間 4,610 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 AC 101 ms
40,504 KB
testcase_02 RE -
testcase_03 AC 120 ms
41,072 KB
testcase_04 RE -
testcase_05 AC 110 ms
40,892 KB
testcase_06 AC 111 ms
40,912 KB
testcase_07 AC 102 ms
39,816 KB
testcase_08 AC 101 ms
39,856 KB
testcase_09 AC 97 ms
40,292 KB
testcase_10 AC 108 ms
41,028 KB
testcase_11 AC 111 ms
40,992 KB
testcase_12 AC 109 ms
41,236 KB
testcase_13 AC 105 ms
40,780 KB
testcase_14 AC 104 ms
40,028 KB
testcase_15 AC 114 ms
40,916 KB
testcase_16 AC 105 ms
40,192 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		String a = sc.next();
		String b = sc.next();
		boolean ba = judge(a);
		boolean bb = judge(b);
		if (ba==true && bb==true) {System.out.println("OK");}
		else {System.out.println("NG");}
	}
	static boolean judge (String s) {
		boolean b;
		
		//1、文字列を含んでいる場合を除去する
		if (s.matches("^[a-zA-Z]*")) {return false;}
		else {
			
			//2、余計な0が含まれている(intにしたときに長さが変わる)場合を除去する
			int before_leng = s.length();
			int after_leng = String.valueOf(Integer.parseInt(s)).length();
			if (before_leng != after_leng) {return false;}
			
			//3、数値の範囲を逸脱している場合を除去する
			if (Integer.parseInt(s) > 12345) {return false;}
			
		}
		//4、何事もなく通過した場合はtrueを返す
		return true;
	}
}
0