結果

問題 No.58 イカサマなサイコロ
ユーザー Lay_ecLay_ec
提出日時 2014-11-08 08:57:27
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 853 bytes
コンパイル時間 729 ms
コンパイル使用メモリ 72,156 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-30 02:39:32
合計ジャッジ時間 1,454 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>

using namespace std;

//dp ver
int main()
{	
	int n,k;
	cin>>n>>k;


	//dp[i][j]=i(>0)つまでの目の和がjになる確率
	double dp_j[11][61]={0},dp_t[11][61]={0};
	dp_j[0][0]=dp_t[0][0]=1.0;

	for(int i=0;i<n;i++){
		for(int j=0;j<=6*n;j++){
			for(int k=1;k<=6;k++) dp_j[i+1][j+k]+=dp_j[i][j]/6;
		}
	}

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

	double res=0;
	for(int i=0;i<=6*n;i++) for(int j=0;j<i;j++) res+=dp_j[n][j]*dp_t[n][i];
	printf("%.16f\n",res);


	return 0;
}
0