結果

問題 No.522 Make Test Cases(テストケースを作る)
ユーザー akakimidoriakakimidori
提出日時 2017-06-03 15:13:17
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 141 ms / 2,000 ms
コード長 547 bytes
コンパイル時間 402 ms
コンパイル使用メモリ 21,860 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-22 02:59:24
合計ジャッジ時間 2,561 ms
ジャッジサーバーID
(参考情報)
judge10 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 5 ms
4,348 KB
testcase_02 AC 4 ms
4,348 KB
testcase_03 AC 10 ms
4,348 KB
testcase_04 AC 0 ms
4,348 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 0 ms
4,348 KB
testcase_07 AC 0 ms
4,348 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 7 ms
4,348 KB
testcase_10 AC 141 ms
4,348 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘run’:
main.c:6:3: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    6 |   scanf("%d",&n);
      |   ^~~~~~~~~~~~~~
main.c: In function ‘run2’:
main.c:19:3: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   19 |   scanf("%d",&n);
      |   ^~~~~~~~~~~~~~

ソースコード

diff #

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

void run(void){
  int n;
  scanf("%d",&n);
  int a,b,c;
  for(a=1;a<=n/3;a++){
    for(b=a;b<=(n-a)/2;b++){
      c=n-a-b;
      printf("%d %d %d\n",a,b,c);
    }
  }
  return;
}

void run2(void){
  int n;
  scanf("%d",&n);
  int a,b,c;
  char *s=(char *)malloc(sizeof(char)*5*3*(n+1));
  int i=0;
  for(a=1;a<=n/3;a++){
    for(b=a;b<=(n-a)/2;b++){
      c=n-a-b;
      i+=sprintf(s+i,"%d %d %d\n",a,b,c);
    }
    printf("%s",s);
    i=0;
  }
  free(s);
  return;
}

int main(void){
  run2();
  return 0;
}
0