結果

問題 No.76 回数の期待値で練習
ユーザー kotatsugamekotatsugame
提出日時 2020-03-06 11:30:19
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 18 ms / 5,000 ms
コード長 448 bytes
コンパイル時間 621 ms
コンパイル使用メモリ 69,748 KB
実行使用メモリ 11,904 KB
最終ジャッジ日時 2024-04-22 03:48:12
合計ジャッジ時間 1,155 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
11,772 KB
testcase_01 AC 18 ms
11,904 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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