ACM: dp题(动态规划) poj 2151 (d…
来源:互联网 发布:深圳阿里云大厦 编辑:程序博客网 时间:2024/06/05 14:39
Description
Organizing a programming contest is not an easy job. To avoidmaking the problems too difficult, the organizer usually expect thecontest result satisfy the following two terms:
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 has studied out the contest problems, and throughthe result of preliminary contest, the organizer can estimate theprobability that a certain team can successfully solve a certainproblem.
Given the number of contest problems M, the number of teams T, andthe number of problems N that the organizer expect the championsolve at least. We also assume that team i solves problem j withthe probability Pij (1 <= i <= T,1<= j <= M). Well, can you calculatethe probability that all of the teams solve at least one problem,and at the same time the champion team solves at least Nproblems?
Input
The input consists of several test cases. The first line of eachtest case contains three integers M (0 < M<= 30), T (1 < T <=1000) and N (0 < N <= M). Each of thefollowing 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 justPij. A test case of M = T = N = 0 indicates the end of input, andshould not be processed.
Output
For each test case, please output the answer in a separate line.The result should be rounded to three digits after the decimalpoint.
Sample Input
2 2 2
0.9 0.9
1 0.9
0 0 0
Sample Output
0.972
题意: ACM比赛出M题,有T个队伍参加,比赛方希望每队至少做出一题,并且至少有一支队伍至少做N题.求概率.
解题思路:
代码:
#include <cstdio>
#include <iostream>
#include <cstring>
using namespace std;
#define MAX 32
#define MAXSIZE 1005
double f[MAXSIZE][MAX];
double g[MAXSIZE][MAX][MAX];
int m, t, n;
int main()
{
//