結果
| 問題 |
No.65 回数の期待値の練習
|
| コンテスト | |
| ユーザー |
hotpepsi
|
| 提出日時 | 2015-07-23 00:12:28 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 527 bytes |
| コンパイル時間 | 513 ms |
| コンパイル使用メモリ | 58,952 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-08 12:10:09 |
| 合計ジャッジ時間 | 1,282 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 16 |
ソースコード
#include <iostream>
#include <algorithm>
#include <sstream>
using namespace std;
double memo[32];
int K;
double e(int x) {
if (x >= K) {
return 0;
}
if (x >= K - 1) {
return 1;
}
double &r = memo[x];
if (r > 0) {
return r;
}
r = e(x + 1) / 6 + e(x + 2) / 6 + e(x + 3) / 6 + e(x + 4) / 6 + e(x + 5) / 6 + e(x + 6) / 6 + 1;
return r;
}
int main(int argc, char *argv[])
{
cout.precision(12);
cin >> K;
for (int i = 0; i < 32; ++i) {
memo[i] = -1;
}
double ans = e(0);
cout << ans << endl;
return 0;
}
hotpepsi