結果

問題 No.785 色食い虫
ユーザー GinFizz1185
提出日時 2019-07-07 19:05:47
言語 C
(gcc 13.3.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 1,080 bytes
コンパイル時間 195 ms
コンパイル使用メモリ 29,696 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-05 05:33:01
合計ジャッジ時間 1,217 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

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