Test instructions: In ACM Contest, the n question, the T team. Give each team the probability of doing each question, ask each team at least one question, at least one team to do at least the probability of the M problem
Analysis: dp,f[i][j] indicates the probability of the first team doing the question J. G[I][J][K] Indicates the probability of the first team to do the K-channel for the first question.
G[I][J][K] = g[i][j-1][k-1] * (F[i][j]) + g[i][j-1][k] * (1-f[i][j]);
With all the G, we can find out the probability that each team will do at least 1 questions: ans *= 1-g[i][n][0];
Subtract each team from only the probability of 1~m-1 (the probability of each team doing the 1~m-1 problem plus and multiplying the results of each team)
Time Limit: 2000MS |
|
Memory Limit: 65536K |
Total Submissions: 5375 |
|
Accepted: 2371 |
Description Organizing a programming contest is a easy job. To avoid making the problems too difficult, the organizer usually expect the contest result satisfy the following S 1. All of the teams solve at least one problem. 2. The champion (one of those teams that solve the most problems) solves at least a certain number of problems.
Now the organizer have studied out the contest problems, and through the result of preliminary contest, the organizer can E Stimate the probability that a certain team can successfully solve a certain problem.
Given the number of contest problems M, the number of teams T, and the number of problems N that the organizer expect the Champion solve at least. We also assume that team I solves problem J with the probability Pij (1 <= i <= T, 1<= J <= M). Well, can-calculate the probability, all of the teams solve at least one problem, and at the same time the Champio N team solves at least n problems?
Input The input consists of several test cases. The first line of all test case contains three integers m (0 < M <=), T (1 < T <=) and N (0 < N &L T;= M). Each of the following T lines contains M floating-point numbers in the range of [0,1]. In these T lines, the j-th number in the i-th line is just pij. A test Case of M = T = N = 0 Indicates the end of input, and should not is processed.Output For each test case, please output the answer-a separate line. The result should is rounded to three digits after the decimal point.Sample Input 2 2 20.9 0.91 0.90 0 0
Sample Output 0.972
Source POJ Monthly, Lu Xiao |
#include <cstdio> #include <iostream> #include <algorithm> #include <cstring>using namespace Std;double f[1001][31];d ouble g[1001][31][31];int main () {int n,t,m; while (~SCANF ("%d%d", &n,&t,&m)} {if (n+t+m==0) break; for (int. I=1; i<=t; i++) for (int j=1; j<=n; j + +) scanf ("%lf", &f[i][j]); memset (G,0,sizeof (g)); for (int i=1; i<=t; i++) {g[i][0][0]=1; for (int j=1; j<=n; J + +) {g[i][j][0]=g[i][j-1][0]* (1-f[i][j]); for (int k=1; k<=j; k++) {g[i][j][k] = g[i][j-1][k-1] * (F[i][j]) + g[i][j-1][k] * (1-f[i][j]); }}} double Ans=1; for (int i=1; i<=t; i++) ans*=1-g[i][n][0]; Ans=1-ans; Double ans2=1; for (int i=1; i<=t; i++) {double ans1=0; for (int j=1;j<m; J + +) Ans1+=g[i][n][j]; ans2*=ans1; } ans-=ans2; printf ("%.3f\n", ans); } return 0;}
Not too difficult a topic, but wrong several times the reason is POJ%lf to replace%f really to kneel 、。。。。
POJ 2151 Check The difficulty of the problems probability DP