結果

問題 No.446 ゆきこーだーの雨と雪 (1)
コンテスト
ユーザー suppy193
提出日時 2016-11-21 14:13:18
言語 C(gnu17)
(gcc 15.2.0)
コンパイル:
gcc-15 -O2 -std=gnu17 -Wno-error=implicit-function-declaration -Wno-error=implicit-int -Wno-error=incompatible-pointer-types -Wno-error=int-conversion -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 726 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 173 ms
コンパイル使用メモリ 38,360 KB
最終ジャッジ日時 2026-02-23 22:58:49
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 13
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function 'main':
main.c:16:13: warning: implicit declaration of function 'atoi' [-Wimplicit-function-declaration]
   16 |         a = atoi(s1);
      |             ^~~~

ソースコード

diff #
raw source code

#include <stdio.h>
#include <string.h>

int main(void) {
	char s1[6], s2[6];
	int a, b;
	int s1_len, s2_len;
	char s_a[6], s_b[6];
	scanf("%s%s", s1, s2);
	//if(s1[0] == '0' || s2[0] == '0'){
	//	printf("NG\n");
	//	return 0;
	//}
	s1_len = strlen(s1);
	s2_len = strlen(s2);
	a = atoi(s1);
	b = atoi(s2);
	//printf("%d %d\n", a, b);
	sprintf(s_a, "%d", a);
	sprintf(s_b, "%d", b);
	if(strlen(s_a) != s1_len || strlen(s_b) != s2_len){
		printf("NG\n");
		return 0;
	}
	else if((s1_len == 1 && (s1[0] < '0' || s1[0] > '9')) ||
	(s2_len == 1 && (s2[0] < '0' || s2[0] > '9'))){
		printf("NG\n");
		return 0;
	}
	else if(a < 0 || a > 12345 || b < 0 || b > 12345){
		printf("NG\n");
		return 0;
	}
	printf("OK\n");
	
	
	return 0;
}
0