Check the difficulty of Problems-poj 2151 (probability +dp)

Source: Internet
Author: User

There are T (1<t<=1000) teams and M (0<m<=30) topics, known to each team I solve each topic J's probability p[i][j], now asked: Each team to solve at least one problem, and the most problem-solving team of the number of questions not less than N (0<n& What is the probability of lt;=m?

P[I][J] Indicates the probability of the first team doing the question J. Dp[i][j][k] indicates that the first team has done the probability of K-channel in the first J question.
Dp[i][j][k] = dp[i][j-1][k-1]* (P[i][j]) +dp[i][j-1][k]* (1-p[i][j]);
Find out the probability that each team will do at least 1 questions: Ans1 *= 1-dp[i][m][0];
Find out that each team only do the right 1 ~ n-1 The probability of the problem ans2 namely: (Each team to do 1 ~ n-1 the probability of adding, and the results of each team multiplied);
Then subtract the two ans1-ans2

1#include <stdio.h>2#include <stdlib.h>3#include <string.h>4 intM,t,n;5 Doublep[1002][ +];6 Doubledp[1002][ +][ +];7 Doublesum[1002][ +];8 intMain () {9scanf" %d%d%d",&m,&t,&N);Ten      while(m&&n&&T) { OneMemset (P,0,sizeof(P)); A          for(intI=1; i<=t;i++){ -              for(intj=1; j<=m;j++){ -scanf"%LF",&p[i][j]); the             } -         } -Memset (DP,0,sizeof(DP)); -          for(intI=1; i<=t;i++){ +dp[i][1][1]=p[i][1]; -dp[i][1][0]=1-p[i][1]; +  A         } at          for(intI=1; i<=t;i++){ -              for(intj=2; j<=m;j++){ -                  for(intk=0; k<=j;k++){ -dp[i][j][k]=dp[i][j-1][k]* (1.0-p[i][j]); -                     if(k>0) dp[i][j][k]+=dp[i][j-1][k-1]*P[i][j]; -                 } in             } -         } tomemset (SUM,0,sizeof(sum)); +          for(intI=1; i<=t;i++){ -sum[i][0]=dp[i][m][0]; the              for(intj=1; j<=m;j++) { *sum[i][j]=sum[i][j-1]+Dp[i][m][j]; $             }Panax Notoginseng         } -         Doubleans1=1.0, ans2=1.0; the          for(intI=1; i<=t; i++)  { +ans1*=sum[i][m]-sum[i][0]; AAns2*= (sum[i][n-1]-sum[i][0]); the             } +printf"%.3lf\n", ans1-ans2); -scanf" %d%d%d",&m,&t,&N); $     } $  -     return 0; -}

Time Limit: 2000MS Memory Limit: 65536K
Total Submissions: 5766 Accepted: 2515

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

Check the difficulty of Problems-poj 2151 (probability +dp)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.