Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 23060 Accepted Submission(s): 9241
#include<iostream> #include<cstdio> #include<cstring> using namespace std; int cost[10005]; double dp[10005],value[10005]; ///value为被录取的概率 int main() { int n,m; while(scanf("%d%d",&n,&m)!=EOF&&!(n==0&&m==0)) { for(int i=0; i<=10005; i++) ///不被录取的概率 dp[i]=1; for(int i=0; i<m; i++) scanf("%d%lf",&cost[i],&value[i]); for(int i=0; i<m; i++) for(int j=n; j>=cost[i]; j--) dp[j]=min(dp[j],dp[j-cost[i]]*(1-value[i])); printf("%.1lf%%\n",(1-dp[n])*100); } return 0;
原文:http://www.cnblogs.com/jasonlixuetao/p/5425191.html