标签:
Description
Input
Output
Sample Input
Sample Output
#include <iostream>
#include <cstdio>
#include <algorithm>
const int maxn=10005;
using namespace std;
int a[maxn];
double dp[maxn],f[maxn];
int main()
{
int n,m,i,j;
while(scanf("%d%d",&n,&m)==2)
{
if(n==0&&m==0)
break;
for(i=0;i<m;i++)
{
scanf("%d%lf",&a[i],&f[i]);
f[i]=1.0-f[i];
}
for(i=0;i<=n;i++)
dp[i]=1.0;
dp[0]=1.0;
for(i=0;i<m;i++)
for(j=n;j>=a[i];j--)
dp[j]=min(dp[j],dp[j-a[i]]*f[i]);
printf("%.1f%%\n",(1.0-dp[n])*100);
}
return 0;
}
标签:
原文地址:http://www.cnblogs.com/xl1164191281/p/4734890.html