[POJ2151]Check the difficulty of problems(概率DP)

Posted 蒟蒻zht的博客

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[POJ2151]Check the difficulty of problems(概率DP)相关的知识,希望对你有一定的参考价值。

传送门

 

每个队之间是独立的

f[i][j]表示当前队伍前i个题答对j个的概率

满足条件的概率 == 全部方案(除去答对0)的概率 - 不满足条件的概率(每个队伍答对1~n-1)

 

#include <cstdio>
#include <cstring>
#define N 101

int m, t, n;
double sum, p1, p2, f[N][N];

int main()
{
	int i, j, k;
	double x;
	while(~scanf("%d %d %d", &m, &t, &n) && (n + m + t))
	{
		p1 = p2 = 1;
		for(i = 1; i <= t; i++)
		{
			memset(f, 0, sizeof(f));
			f[0][0] = 1;
			for(j = 1; j <= m; j++)
			{
				scanf("%lf", &x);
				for(k = 0; k <= j; k++)
				{
					if(k) f[j][k] += f[j - 1][k - 1] * x;
					f[j][k] += f[j - 1][k] * (1.0 - x);
				}
			}
			sum = 0;
			for(j = 1; j < n; j++) sum += f[m][j];
			p1 *= 1.0 - f[m][0];
			p2 *= sum;
		}
		printf("%.3lf\n", p1 - p2);
	}
	return 0;
}

  

以上是关于[POJ2151]Check the difficulty of problems(概率DP)的主要内容,如果未能解决你的问题,请参考以下文章

[ACM] POJ 2151 Check the difficulty of problems (概率+DP)

POJ 2151:Check the difficulty of problems 概率DP

POJ 2151 Check the difficulty of problems:概率dp至少

POJ 2151 Check the difficulty of problems(概率DP)

POJ2151Check the difficulty of problems

POJ 2151 Check the difficulty of problems