結果

問題 No.76 回数の期待値で練習
ユーザー hotpepsihotpepsi
提出日時 2016-02-21 00:26:28
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 20 ms / 5,000 ms
コード長 628 bytes
コンパイル時間 504 ms
コンパイル使用メモリ 57,416 KB
実行使用メモリ 11,680 KB
最終ジャッジ日時 2023-10-23 18:44:28
合計ジャッジ時間 1,289 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <sstream>

using namespace std;

double p[7] = { 0, 1.0 / 12, 2.0 / 12, 3.0 / 12, 1.0 / 12, 3.0 / 12, 2.0 / 12 };
double dp[1000001] = { 0, 1.0000000000000000, 1.0833333333333333, 1.2569444444444444, 1.5353009259259260, 1.6915991512345676, 2.0513639724794235 };

int main(int argc, char *argv[])
{
	cout.precision(12);
	for (int i = 7; i <= 1000000; ++i) {
		dp[i] = 1 + dp[i - 1] * p[1] + dp[i - 2] * p[2] + dp[i - 3] * p[3] + dp[i - 4] * p[4] + dp[i - 5] * p[5] + dp[i - 6] * p[6];
	}
	int T;
	cin >> T;
	for (int i = 0; i < T; ++i) {
		int n;
		cin >> n;
		cout << dp[n] << endl;
	}
	return 0;
}
0