結果
| 問題 |
No.65 回数の期待値の練習
|
| コンテスト | |
| ユーザー |
hogeover30
|
| 提出日時 | 2015-02-04 13:59:57 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 401 bytes |
| コンパイル時間 | 532 ms |
| コンパイル使用メモリ | 61,824 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-23 07:26:39 |
| 合計ジャッジ時間 | 1,294 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 16 |
ソースコード
#include <iostream>
#include <iomanip>
using namespace std;
double memo[200];
double func(int x, int K)
{
if (x>=K) return 0;
double& res=memo[x];
if (res>0) return res;
res=1;
for(int i=1;i<=6;++i) res+=func(x+i,K)/6;
return res;
}
int main()
{
int K;
while (cin>>K) {
for(int i=0;i<200;++i) memo[i]=0;
cout<<setprecision(10)<<func(0,K)<<endl;
}
}
hogeover30