結果

問題 No.76 回数の期待値で練習
ユーザー ttkkggwwttkkggww
提出日時 2020-04-08 03:17:47
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 600 ms / 5,000 ms
コード長 771 bytes
コンパイル時間 1,453 ms
コンパイル使用メモリ 165,784 KB
実行使用メモリ 18,780 KB
最終ジャッジ日時 2023-09-23 00:29:47
合計ジャッジ時間 2,583 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll = long long;

double p[6];
double E[6];
vector<double> dp;
int main()
{
	int t;
	cin >> t;
	E[0] = 1.0000000000000000;
	E[1] = 1.0833333333333333;
	E[2] = 1.2569444444444444;
	E[3] = 1.5353009259259260;
	E[4] = 1.6915991512345676;
	E[5] = 2.0513639724794235;
	p[0] = E[1]-1;
	p[1] = E[2]-E[1]*p[0]-1;
	p[2] = E[3]-E[2]*p[0]-E[1]*p[1]-1;
	p[3] = E[4]-E[3]*p[0]-E[2]*p[1]-E[1]*p[2]-1;
	p[4] = E[5]-E[4]*p[0]-E[3]*p[1]-E[2]*p[2]-E[1]*p[3]-1;
	p[5] = 1-p[0]-p[1]-p[2]-p[3]-p[4];
	
	for(int ii = 0;ii<t;ii++)
	{
		dp = vector<double>(1000010,0);
		int x;
		cin >> x;
		for(int i = x-1;i>=0;i--)
		{
			for(int j = 0;j<6;j++)
			{
				dp[i] += (dp[i+j+1]+1.0)*p[j];
			}
		}
		printf("%.15lf\n",dp[0]);
		

	}
	return 0;
}
0