标签:printf 独立 logs fine scanf difficult double efi 方案
每个队之间是独立的
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)
标签:printf 独立 logs fine scanf difficult double efi 方案
原文地址:http://www.cnblogs.com/zhenghaotian/p/7577210.html