結果

問題 No.65 回数の期待値の練習
ユーザー imulan
提出日時 2016-02-08 18:56:02
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 497 bytes
コンパイル時間 1,376 ms
コンパイル使用メモリ 157,020 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-21 21:49:18
合計ジャッジ時間 2,343 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define rep(i,n) for(i=0;i<n;++i)
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); itr++)
#define mp make_pair
#define pb push_back
#define fi first
#define sc second

int main(int argc, char const *argv[]) {
  int i,j;

  int k;
  cin >>k;

  double e[31];
  rep(i,31) e[i]=0;

  for(i=k-1; i>=0; --i){
    e[i]=1;
    for(j=1; j<=6; ++j) e[i]+=e[i+j]/6.0;
  }

  printf("%.10lf\n",e[0]);
  return 0;
}
0