結果

問題 No.446 ゆきこーだーの雨と雪 (1)
ユーザー GrenacheGrenache
提出日時 2016-11-18 22:29:42
言語 Java21
(openjdk 21)
結果
AC  
実行時間 113 ms / 2,000 ms
コード長 972 bytes
コンパイル時間 3,176 ms
コンパイル使用メモリ 73,828 KB
実行使用メモリ 56,172 KB
最終ジャッジ日時 2023-08-17 10:55:49
合計ジャッジ時間 5,914 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 112 ms
55,532 KB
testcase_01 AC 110 ms
53,864 KB
testcase_02 AC 110 ms
55,484 KB
testcase_03 AC 110 ms
54,276 KB
testcase_04 AC 111 ms
56,172 KB
testcase_05 AC 111 ms
55,472 KB
testcase_06 AC 111 ms
55,484 KB
testcase_07 AC 110 ms
55,936 KB
testcase_08 AC 111 ms
55,772 KB
testcase_09 AC 110 ms
55,772 KB
testcase_10 AC 110 ms
55,896 KB
testcase_11 AC 109 ms
55,808 KB
testcase_12 AC 111 ms
55,636 KB
testcase_13 AC 111 ms
55,772 KB
testcase_14 AC 111 ms
55,564 KB
testcase_15 AC 110 ms
55,620 KB
testcase_16 AC 113 ms
55,928 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;


public class Main_yukicoder446 {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		char[] a = sc.next().toCharArray();
		char[] b = sc.next().toCharArray();

		if (isOK(a) && isOK(b)) {
			pr.println("OK");
		} else {
			pr.println("NG");
		}
	}

	private static boolean isOK(char[] a) {
		for (char c : a) {
			if (c < '0' || c > '9') {
				return false;
			}
		}

		int n = Integer.parseInt(String.valueOf(a));

		if (n == 0 && a.length > 1) {
			return false;
		}

		if (a[0] == '0' && n > 0) {
			return false;
		}

		if (n > 12345) {
			return false;
		}

		return true;
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);

		solve();

		pr.close();
		sc.close();
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}
0