結果

問題 No.58 イカサマなサイコロ
ユーザー snrnsidysnrnsidy
提出日時 2021-12-24 05:35:07
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 3 ms / 5,000 ms
コード長 971 bytes
コンパイル時間 4,975 ms
コンパイル使用メモリ 202,292 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-19 05:52:33
合計ジャッジ時間 2,741 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 3 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 3 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 3 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

double dp[11][61];
double dp2[11][61];

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	dp[0][0] = 1;
	dp2[0][0] = 1;

	int n,k;

	cin >> n;
	cin >> k;

	for(int i=0;i<n;i++)
	{
		for(int j=10*n;j>=0;j--)
		{
			for(int x=1;x<=6;x++)
			{
				if(j+x<=6*n)
				{
					dp[i+1][j+x] += (dp[i][j]/6);
				}
			}
		}
	}

	for(int i=0;i<n;i++)
	{
		if(i < k)
		{
			for(int j=10*n;j>=0;j--)
			{
				for(int x=4;x<=6;x++)
				{
					if(j+x<=6*n)
					{
						dp2[i+1][j+x] += (dp2[i][j]/3);
					}
				}
			}
		}
		else
		{
			for(int j=10*n;j>=0;j--)
			{
				for(int x=1;x<=6;x++)
				{
					if(j+x<=6*n)
					{
						dp2[i+1][j+x] += (dp2[i][j]/6);
					}
				}
			}			
		}
	}	

	double res = 0;

	for(int i=0;i<=6*n;i++)
	{
		//cout << i << ' ' << dp[n][i] << '\n';
		for(int j=i+1;j<=6*n;j++)
		{
			res += (dp[n][i]*dp2[n][j]);
		}
	}

	cout << fixed;
	cout.precision(6);

	cout << res << '\n';

	return 0;
}
0