結果

問題 No.567 コンプリート
ユーザー akakimidoriakakimidori
提出日時 2018-08-02 04:34:03
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 231 ms / 2,000 ms
コード長 643 bytes
コンパイル時間 641 ms
コンパイル使用メモリ 23,800 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-19 20:57:56
合計ジャッジ時間 1,611 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void run(void){
  int n;
  scanf("%d",&n);
  const int f=6;
  const double p=(double)1/f;
  double *now=(double *)calloc(f+1,sizeof(double));
  now[1]=1;
  double *next=(double *)calloc(f+1,sizeof(double));
  int i;
  for(i=2;i<=n;i++){
    int j;
    for(j=1;j<=f;j++){
      next[j]=now[j]*(j*p)+now[j-1]*((f-(j-1))*p);
    }
    double *swap=now;
    now=next;
    next=swap;
  }
  printf("%.9lf\n",now[f]);
}

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