結果

問題 No.785 色食い虫
ユーザー GinFizz1185GinFizz1185
提出日時 2019-07-07 19:05:47
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 1,080 bytes
コンパイル時間 236 ms
コンパイル使用メモリ 30,464 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-15 10:50:56
合計ジャッジ時間 1,467 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 1 ms
5,376 KB
testcase_13 AC 1 ms
5,376 KB
testcase_14 AC 1 ms
5,376 KB
testcase_15 AC 1 ms
5,376 KB
testcase_16 AC 1 ms
5,376 KB
testcase_17 AC 1 ms
5,376 KB
testcase_18 AC 1 ms
5,376 KB
testcase_19 AC 1 ms
5,376 KB
testcase_20 AC 1 ms
5,376 KB
testcase_21 AC 1 ms
5,376 KB
testcase_22 AC 1 ms
5,376 KB
testcase_23 AC 1 ms
5,376 KB
testcase_24 AC 1 ms
5,376 KB
testcase_25 AC 1 ms
5,376 KB
testcase_26 AC 1 ms
5,376 KB
testcase_27 AC 1 ms
5,376 KB
testcase_28 AC 1 ms
5,376 KB
testcase_29 AC 1 ms
5,376 KB
testcase_30 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#define STR_LENGTH 33

unsigned char count_str(char*);

int main(void) {
  unsigned char r = 0;
  unsigned char b = 0;
  unsigned char g = 0;
  char str[STR_LENGTH];
  unsigned int ans = 0;

  fgets(str, sizeof(str), stdin);
  if(0 == strcmp(str, "NONE\n")) {
    r = 16;
  } else {
    r = 16 - count_str(str);
  }

  fgets(str, sizeof(str), stdin);
  if(0 == strcmp(str, "NONE\n")) {
    g = 16;
  } else {
    g = 16 - count_str(str);
  }

  fgets(str, sizeof(str), stdin);
  if(0 == strcmp(str, "NONE\n")) {
    b = 16;
  } else {
    b = 16 - count_str(str);
  }

  ans = r * r * g * g * b * b;

  printf("%d\n", ans);
  return 0;
}

/*
関数概要:渡された文字列の文字数カウントを行う
第1引数:文字列
戻り値:与えられた文字列の文字数を返す 0 < ret <= 16
*/
unsigned char count_str(char* str) {
  unsigned char count = 0; //文字数
  int i = 0;

  while('\0' != str[i]){
    if((',' != str[i]) && ('\n' != str[i])){
      count++;
    }
    ++i;
  }

  return count;
}
0