結果
| 問題 |
No.446 ゆきこーだーの雨と雪 (1)
|
| コンテスト | |
| ユーザー |
sasa
|
| 提出日時 | 2025-03-10 14:08:09 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 2,000 ms |
| コード長 | 797 bytes |
| コンパイル時間 | 366 ms |
| コンパイル使用メモリ | 28,672 KB |
| 実行使用メモリ | 7,324 KB |
| 最終ジャッジ日時 | 2025-03-10 14:08:11 |
| 合計ジャッジ時間 | 1,658 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 13 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:6:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
6 | scanf("%s%s", str1, str2);
| ~~~~~^~~~~~~~~~~~~~~~~~~~
ソースコード
#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;
}
sasa