表示这么傻逼的题还想了这么久,感觉好傻逼,暴力dp生上就可以了,卡内存恶心死了,结果稍微一减就A了。
f[i][j][k]表示前i场已经胜利j场背包容量为k的概率
f[i][j][k]-->f[i+1][j+1][k+a[i]]
-->f[i+1][j+1][k]
ans=sigma(f[n][L][k])(k>=0)
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<algorithm>
#define maxn 201
using namespace std;
double f[maxn][maxn][401],p[maxn];
int n,l,k,a[maxn];
void modify(int i,int j,int k,double x)
{
if (k>n) k=n;
f[i][j][k+200]+=x;
}
int main()
{
scanf("%d%d%d",&n,&l,&k);
for (int i=1;i<=n;i++)
{
int x;
scanf("%d",&x);
p[i]=(double)x/100.0;
}
for (int i=1;i<=n;i++) scanf("%d",&a[i]);
if (k>n) k=n;
f[0][0][k+200]=1;
for (int i=0;i<n;i++)
for (int j=0;j<=i;j++)
for (int k=-i;k<=n;k++)
modify(i+1,j+1,k+a[i+1],p[i+1]*f[i][j][k+200]),modify(i+1,j,k,(1-p[i+1])*f[i][j][k+200]);
double ans=0;
for (int i=0;i<=n;i++)
for (int j=l;j<=n;j++)
ans+=f[n][j][i+200];
printf("%.6lf\n",ans);
return 0;
}