結果

問題 No.446 ゆきこーだーの雨と雪 (1)
ユーザー yukiteru
提出日時 2018-02-07 21:53:28
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,171 bytes
コンパイル時間 700 ms
コンパイル使用メモリ 83,976 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-19 00:27:51
合計ジャッジ時間 1,449 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<utility>
#include<stack>
#include<queue>
#include<list>
#include<bitset>
#include<functional>

#define FOR(i, a, b) for(int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000
#define PI 3.14159265358979

using namespace std;
typedef pair<int, int> P;

int main(void) {
	string s;
	string t;
	int p = 0, q = 0;
	bool flag = true;

	cin >> s >> t;

	FOR(i, 0, s.size() - 1) {
		if (s[i]<'0' || s[i]>'9') {
			flag = false;
			break;
		}
	}
	FOR(i, 0, t.size() - 1) {
		if (t[i]<'0' || t[i]>'9') {
			flag = false;
			break;
		}
	}
	if (s.size() != 1 && s[0] == '0') {
		flag = false;
	}
	if (t.size() != 1 && t[0] == '0') {
		flag = false;
	}
	if (flag == false) {
		cout << "NG" << endl;
	}
	else {
		FOR(i, 0, s.size() - 1) {
			p += (s[i] - '0')*pow(10, s.size() - 1 - i);
		}
		FOR(i, 0, t.size() - 1) {
			q += (t[i] - '0')*pow(10, t.size() - 1 - i);
		}
		if (p <= 12345 && q <= 12345) {
			cout << "OK" << endl;
		}
		else {
			cout << "NG" << endl;
		}
	}

	return 0;
}
0