Language:DefaultCheck the difficulty of problems
Time Limit: 2000MS |
|
Memory Limit: 65536K |
Total Submissions: 5419 |
|
Accepted: 2384 |
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
|
Test instructions: N person, M problem, ask each person to make a problem, and at least one to make a K-question probability
Idea: equal to each person to do the probability of the question--everyone to do the quiz and no one to make K-to-Q probability
#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include < cmath> #include <queue> #include <stack> #include <vector> #include <set> #include <map > #define L (x) (x<<1) #define R (x) (x<<1|1) #define MID (x, y) ((x+y) >>1) #define EPS 1e-8typedef __ Int64 ll; #define FRE (i,a,b) for (i = A; I < b; i++) #define FREE (i,b,a) for (i = b; I >= a;i--) #define MEM (T, v) mem Set ((t), V, sizeof (t)) #define SSF (n) scanf ("%s", N) #define SF (n) scanf ("%d", &n) #define SFF (A, b) scanf ("%d%d", &a, &b) #define SFFF (a,b,c) scanf ("%d%d%d", &a, &b, &c) #define PF Printf#define bu G PF ("hi\n") using namespace std, #define INF 0x3f3f3f3f#define n 1005double dp[n][35][35]; Dp[i][j][k] The first person of the first J to do K-way probability double p[n][35];int n,m,k;void solve () {int i,j,t;mem (dp,0); FRE (i,1,n+1)//Initial each person first question right and wrong {dp[i][1][0]=1-p[i][1];dp [i][1][1]=p[i][1]; }fre (I,1,N+1)//each person m to the question is not against {fre (j,2,m+1) dp[i][j][0]=dp[i][j-1][0]* (1-p[i][j]);} FRE (i,1,n+1)//J-Question per person do T-Channel probability fre (j,2,m+1) fre (t,1,j+1) {if (t<j) dp[i][j][t]=dp[i][j-1][t]* (1-p[i][j]) +DP I [J-1] [T-1]*p[i][j]; else Dp[i][j][t]=dp[i][j-1][t-1]*p[i][j]; } double p1=1,p2; Fre (i,1,n+1) p1*= (1-dp[i][m][0]); Everyone makes a p2=1 probability of mentioning; Fre (i,1,n+1) {double te=0; Fre (j,1,k) te+=dp[i][m][j]; P2*=te; Everyone does a quiz but there is no probability of a K-question}pf ("%.3lf\n", P1-P2);} int main () {int i,j;while (~SFFF (m,n,k), n+m+k) {fre (i,1,n+1) fre (j,1,m+1) scanf ("%lf", &p[i][j]); Solve ();} return 0;}
POJ 2151 Check The difficulty of problems (probability DP)