結果

問題 No.76 回数の期待値で練習
ユーザー kotatsugame
提出日時 2020-03-06 11:30:19
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 22 ms / 5,000 ms
コード長 448 bytes
コンパイル時間 600 ms
コンパイル使用メモリ 69,376 KB
実行使用メモリ 11,904 KB
最終ジャッジ日時 2024-10-14 02:41:33
合計ジャッジ時間 1,076 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 2
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:6:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    6 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<iomanip>
using namespace std;
double p[]={0.08333333333333326,0.16666666666666674,0.2500000000000001,0.08333333333333298,0.24999999999999983,0.16666666666666707};
double dp[1<<20];
main()
{
	dp[0]=0;
	for(int i=1;i<1<<20;i++)
	{
		double t=0;
		for(int j=0;j<6;j++)
		{
			if(i-1-j>0)t+=p[j]*dp[i-1-j];
		}
		dp[i]=t+1;
	}
	int T;cin>>T;
	for(;T--;)
	{
		int K;cin>>K;
		cout<<fixed<<setprecision(16)<<dp[K]<<endl;
	}
}
0