超水的动态规划。最后要对概率求Sigma。
#include <cstdio>
#include <cstring>
#include <cstdlib> #define MAXN 61
#define MAXK 11 double dp[MAXK][MAXN];
double a[];
int b[] = {, , , , , , , , , }; int main() {
int t;
int i, j, k, p; #ifndef ONLINE_JUDGE
freopen("data.in", "r", stdin);
#endif scanf("%d", &t);
for (p=; p<t; ++p) {
for (i=; i<=; ++i)
scanf("%lf", &a[i]);
for (i=; i<MAXK; ++i)
for (j=; j<MAXN; ++j)
dp[i][j] = 0.0;
dp[][] = 1.0;
for (i=; i<MAXK; ++i) {
for (k=; k<MAXN; ++k) {
for (j=; j<=; ++j) {
if (k+j < MAXN)
dp[i][k+j] += dp[i-][k]*a[j];
else
break;
}
}
}
if (p)
printf("\n");
double sum;
for (i=; i<; ++i) {
sum = 0.0;
for (j=; j<MAXK; ++j)
sum += dp[j][b[i]];
printf("%d: %.1lf%%\n", b[i], sum*);
}
} return ;
}