結果

問題 No.446 ゆきこーだーの雨と雪 (1)
コンテスト
ユーザー sasa
提出日時 2025-03-10 14:08:09
言語 C++14
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 797 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 165 ms
コンパイル使用メモリ 39,936 KB
実行使用メモリ 5,760 KB
最終ジャッジ日時 2026-07-07 01:15:40
合計ジャッジ時間 1,429 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include<stdio.h>
#include<string.h>
int main()
{
	char str1[8], str2[8];
	scanf("%s%s", str1, str2);
	int i, len1, len2;
	len1 = strlen(str1);
	for (i = 0; i < len1; i++)
	{
		if (str1[i] < '0' || '9' < str1[i])
		{
			printf("NG\n");
			return 0;
		}
	}
	if (len1 > 1 && str1[0] == '0')
	{
		printf("NG\n");
		return 0;
	}
	len2 = strlen(str2);
	for (i = 0; i < len2; i++)
	{
		if (str2[i] < '0' || '9' < str2[i])
		{
			printf("NG\n");
			return 0;
		}
	}
	if (len2 > 1 && str2[0] == '0')
	{
		printf("NG\n");
		return 0;
	}
	int x = 0;
	for (i = 0; i < len1; i++)
		x = 10 * x + str1[i] - '0';
	if (x > 12345)
	{
		printf("NG\n");
		return 0;
	}
	x = 0;
	for (i = 0; i < len2; i++)
		x = 10 * x + str2[i] - '0';
	if (x > 12345)
	{
		printf("NG\n");
		return 0;
	}
	printf("OK\n");
	return 0;
}
0