题意:有M个问题,T个团队,给出每个团队解决出每个问题的概率, 求没个团队至少解决出一道问题,且最多解题书的团队至少解决了N个问题的概率。
先求出每个团队至少解决一道题的概率p(1 - 每个团队解决0个问题的概率),
再算出每个团队都解决出小于N个问题(大于1)的概率ans
则答案为 p - ans
#include<iostream>
#include<cstring>
#include<string>
#include<cstdio>
#include<stdio.h>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<queue>
using namespace std;
#define inf 0x3f3f3f3f
#define eps 1e-9
#define mod 10007
#define FOR(i,s,t) for(int i = s; i < t; ++i )
#define REP(i,s,t) for( int i = s; i <= t; ++i )
#define LL long long
#define ULL unsigned long long
#define pii pair<int,int>
#define MP make_pair
#define lson id << 1 , l , m
#define rson id << 1 | 1 , m + 1 , r
#define maxn ( 1000+10 )
#define maxe ( 20000+10 )
#define mxn 20000
double dp[maxn][33][33];
double a[maxn][33];
int main () {
int n, t, m;
while( ~scanf("%d%d%d", &m, &t, &n ) ) {
if( m == 0 && n == 0 && t == 0 ) break;
double p = 1.0;
for( int i = 0; i < t; ++i ) {
double tmp = 1.0;
for( int j = 1; j <= m; ++ j )
scanf("%lf", &a[i][j] ), tmp *= ( 1 - a[i][j] );
p *= ( 1 - tmp );
}
memset( dp, 0, sizeof( dp ) );
for( int i = 0; i < t; ++i )
{
dp[i][0][0] = 1;
for( int j = 1; j <= m; ++j ) {
for( int k = 0; k <= j ; ++k ) {
if( k > 0 ) dp[i][j][k] = dp[i][j-1][k-1] * a[i][j];
dp[i][j][k] += dp[i][j-1][k] * ( 1 - a[i][j] );
}
}
}
double ans = 1.0;
for( int i = 0; i < t; ++i ){
double tmp = 0.0;
for( int j = 1; j < n; ++j )
tmp += dp[i][m][j];
ans *= tmp;
}
ans = p - ans;
printf("%.3lf\n", ans );
}
}