結果

問題 No.76 回数の期待値で練習
ユーザー motxxmotxx
提出日時 2014-11-24 01:06:02
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 464 bytes
コンパイル時間 2,615 ms
コンパイル使用メモリ 142,960 KB
実行使用メモリ 11,552 KB
最終ジャッジ日時 2023-08-30 22:40:39
合計ジャッジ時間 1,637 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 27 ms
11,420 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)

double base[6] = {1.0/12, 2.0/12, 3.0/12, 1.0/12, 3.0/12, 2.0/12};


double dp[1000010];

int main() {
  
  rep(i, 1000001) {
    dp[i] = 1.;
    REP(j, 1, 7) if(i-j >= 0) { dp[i] += dp[i-j] * base[j-1]; }
  }
  int T; cin >> T;
  while(T--) {
    int N; cin >> N;
    printf("%.15f\n", dp[N]);
  }
  
  return 0;
}
0