标签:
Description
Input
Output
Sample Input
10 3 4 0.1 4 0.2 5 0.3 0 0
Sample Output
44.0%
Hint
#include<iostream> #include<cstring> #include<stdio.h> using namespace std; const int maxx = 10005; int n,m; int w[maxx]; double v[maxx]; double dp[maxx]; int main() { while(scanf("%d%d",&n,&m)&&(n+m)!=0) { for(int i=0;i<m;i++) { scanf("%d%lf",w+i,v+i); v[i]=(1-v[i]); } //memset(dp,1.0,sizeof(dp)); for(int i=0;i<=n;i++) dp[i]=1.0; //cout<<dp[n]<<endl; for(int i=0;i<m;i++) { for(int j=n;j>=w[i];j--) { dp[j]=min(dp[j-w[i]]*v[i],dp[j]); } } printf("%.1lf%%\n",(1-dp[n])*100); } return 0; }
标签:
原文地址:http://www.cnblogs.com/superxuezhazha/p/5752549.html