結果

問題 No.883 ぬりえ
ユーザー GinFizz1185GinFizz1185
提出日時 2019-11-19 22:03:03
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 1,906 bytes
コンパイル時間 943 ms
コンパイル使用メモリ 32,768 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-15 02:09:22
合計ジャッジ時間 2,204 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#define STR_LENGTH 10

void str_cut(char*, int*);
void paint(int, int, int);


int main(void)
{
  char str[STR_LENGTH];
  int input[3] = {0};
  int numCR1 = 0;
  int numCR2 = 0;
  int numCR  = 0;
  int count = 0;
  int bCount = 0;
  int nextColumn= 0;
  int nextRow = 0;
  float decimal = 0.0;

  fgets(str, sizeof(str), stdin);
  str_cut(str, input);

  decimal = sqrt(input[0]);
  // printf("decimal1 = %f\n", decimal);
  numCR1 = (int)decimal;
  if(0 < (decimal - numCR1))
  {
    numCR1 += 1;
  }
  // printf("numCR1 = %d\n", numCR1);

  decimal = input[0] / input[1];
  // printf("decimal2 = %f\n", decimal);
  numCR2 = (int)decimal;
  if(0 < (decimal - numCR2))
  {
    numCR2 += 1;
  }
  // printf("numCR2 = %d\n", numCR2);

  if(numCR1 >= numCR2)
  {
    numCR = numCR1;
  } else
  {
    numCR = numCR2;
  }

  printf("%d\n", numCR);

  nextRow = input[1];

  for(int i=0; i < numCR; i++)
  {
    if(i >= nextRow)
    {
      nextColumn += input[1];
      nextRow += input[1];
    }
    for(int j=0; j < numCR; j++)
    {
      if(bCount == input[0])
      {
        printf(".");
        continue;
      }
      if((count < input[1]) && (nextColumn <= j))
      {
        printf("#");
        count += 1;
        bCount += 1;
      }
      else
      {
        printf(".");
      }
    }
    printf("\n");
    count = 0;
  }



  return 0;
}

/*
関数概要:渡された文字列を空白で分離し、数値に変換する
第1引数:文字列
第2引数:文字列から数値に変換して格納する配列
*/
void str_cut(char* str, int* arg2)
{
  int start_str = 0;
  int num = 0; //配列NO
  int i = 0;

  while('\0' != str[i]){
    if(' ' == str[i]){
      str[i] = '\0';
      arg2[num] = atoi(&str[start_str]);
      ++num;
      ++i;
      start_str = i;
    }
    ++i;
  }

  arg2[num] = atoi(&str[start_str]);

  return;
}
0