結果

問題 No.58 イカサマなサイコロ
ユーザー kyuridenamidakyuridenamida
提出日時 2016-02-16 05:42:36
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 3 ms / 5,000 ms
コード長 772 bytes
コンパイル時間 1,286 ms
コンパイル使用メモリ 159,724 KB
実行使用メモリ 5,884 KB
最終ジャッジ日時 2023-10-22 05:58:58
合計ジャッジ時間 1,876 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0 ; (i) < (int)(n) ; (i)++)
#define REP(i,a,b) for(int (i) = a ; (int)(i) <= (int)(b) ; (i)++)
#define all(n) (n).begin(),(n).end()
typedef long long ll;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<long long,long long> Pii;
typedef vector<Pii> VPii;


double dp[114][114][114];
bool ok[114][114][114];

int N,K;
double dfs(int x,int a,int b){
	if( x == 0 ) return a < b;
	if( ok[x][a][b] ) return dp[x][a][b];
	
	double ans = 0;
	int c = 0;
	for(int i = 1 ; i <= 6 ; i++){
		for(int j = (x<=K?4:1) ; j <= 6 ; j++){
			ans += dfs(x-1,a+i,b+j);
			c++;
		}
	}
	ok[x][a][b] = true;
	return dp[x][a][b] = ans / c;
}

int main(){
	
	cin >> N >> K;
	printf("%.10lf\n",dfs(N,0,0));
	
}
0