結果
| 問題 |
No.76 回数の期待値で練習
|
| コンテスト | |
| ユーザー |
kurenai3110
|
| 提出日時 | 2016-09-15 22:49:28 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 27 ms / 5,000 ms |
| コード長 | 499 bytes |
| コンパイル時間 | 456 ms |
| コンパイル使用メモリ | 61,780 KB |
| 実行使用メモリ | 11,520 KB |
| 最終ジャッジ日時 | 2024-11-17 06:15:59 |
| 合計ジャッジ時間 | 891 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 2 |
ソースコード
#include <iostream>
#include <iomanip>
using namespace std;
double DP[1000007];
double p[7];
int main()
{
p[1] = 1. / 12;
p[2] = 2. / 12;
p[3] = 3. / 12;
p[4] = 1. / 12;
p[5] = 3. / 12;
p[6] = 2. / 12;
for (int i = 1; i < 1000001; i++) {
DP[i] = 1;
for (int j = 1; j <= 6; j++) {
if (i - j > 0) {
DP[i] += DP[i - j] * p[j];
}
}
}
int t;
cin >> t;
for (int i = 0; i < t; i++) {
int n; cin >> n;
cout << fixed << setprecision(6) << DP[n] << endl;
}
return 0;
}
kurenai3110