結果
| 問題 | No.76 回数の期待値で練習 |
| コンテスト | |
| ユーザー |
kurenai3110
|
| 提出日時 | 2016-09-15 22:49:28 |
| 言語 | C++11 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 22 ms / 5,000 ms |
| コード長 | 499 bytes |
| 記録 | |
| コンパイル時間 | 362 ms |
| コンパイル使用メモリ | 75,632 KB |
| 実行使用メモリ | 11,840 KB |
| 最終ジャッジ日時 | 2026-05-12 06:41:15 |
| 合計ジャッジ時間 | 1,036 ms |
|
ジャッジサーバーID (参考情報) |
judge1_1 / tmp-judge_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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