結果

問題 No.76 回数の期待値で練習
ユーザー kurenai3110kurenai3110
提出日時 2016-09-15 22:49:28
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 27 ms / 5,000 ms
コード長 499 bytes
コンパイル時間 416 ms
コンパイル使用メモリ 62,396 KB
実行使用メモリ 11,408 KB
最終ジャッジ日時 2023-08-10 20:44:06
合計ジャッジ時間 923 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
11,308 KB
testcase_01 AC 27 ms
11,408 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0