結果
| 問題 |
No.65 回数の期待値の練習
|
| コンテスト | |
| ユーザー |
machy
|
| 提出日時 | 2015-06-14 11:41:57 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 555 bytes |
| コンパイル時間 | 601 ms |
| コンパイル使用メモリ | 75,988 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-06 20:06:19 |
| 合計ジャッジ時間 | 1,237 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 16 |
ソースコード
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <iomanip>
#include <map>
#include <numeric>
using namespace std;
typedef long long LL;
vector<double> memo(21, -1.0);
double solve(int K){
if(K <= 0) return 0.0;
if(memo[K] >= 0.0) return memo[K];
double exp = 0.0;
for(int i = 1; i <= 6; i++){
exp += 1.0/6.0 * (solve(K-i) + 1.0);
}
memo[K] = exp;
return exp;
}
int main(){
LL K;
cin >> K;
cout << setprecision(13) << solve(K) << endl;
return 0;
}
machy