結果

問題 No.446 ゆきこーだーの雨と雪 (1)
ユーザー rtomp
提出日時 2016-11-22 20:31:44
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 649 bytes
コンパイル時間 510 ms
コンパイル使用メモリ 56,776 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-27 09:42:10
合計ジャッジ時間 1,022 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>

using namespace std;

const string _Limit = "12345";

bool Juge(string target)
{
	// 2桁以上で先頭が"0"は失格
	if (target.length() != 1 && target[0] == '0') return false;

	// 0-9以外が含まれていたら失格
	for (string::const_iterator i = target.begin(); i != target.end(); i++)
	{
		if (*i < '0' || *i > '9') return false;
	}

	// 辞書順比較で失格判定
	if (target.length() == 5 && target > _Limit) return false;

	return true;
}

void Slove()
{
	string a, b;
	cin >> a >> b;

	bool ans = (Juge(a) && Juge(b));

	cout << (ans ? "OK" : "NG") << endl;
}


int main()
{
	Slove();
}
0