結果

問題 No.446 ゆきこーだーの雨と雪 (1)
ユーザー HimatsubushinHimatsubushin
提出日時 2022-03-02 13:44:10
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 794 bytes
コンパイル時間 1,599 ms
コンパイル使用メモリ 27,676 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-23 07:00:46
合計ジャッジ時間 2,321 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 0 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 0 ms
4,376 KB
testcase_04 AC 0 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 0 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 0 ms
4,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 0 ms
4,376 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 0 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

bool check1(char *);
bool check2(char *);

int main(void) {
  char in1[6], in2[6];
  
  scanf("%s", in1);
  scanf("%s", in2);

  if (!check1(in1)) return EXIT_SUCCESS;
  if (!check1(in2)) return EXIT_SUCCESS;
  if (!check2(in1)) return EXIT_SUCCESS;
  if (!check2(in2)) return EXIT_SUCCESS;

  printf("OK");
  
  return EXIT_SUCCESS;
}

bool check1(char *s) {
  int num;
  
  sscanf(s, "%d", &num);

  if (num > 12345) {
    printf("NG");
    return false;
  }

  return true;
}

bool check2(char *s) {
  if (*s == '0' && strlen(s) > 1) {
    printf("NG");
    return false;
  }

  while (*s != '\0') {
    if (*s < '0' || *s > '9') {
      printf("NG");
      return false;
    }
    s++;
  }

  return  true;
}
0