标签:
#include<stdio.h> #include<string.h> #include<algorithm> #include<queue> using namespace std; #define N 50000 int a[N],dp[N]; int main() { int n,m,c[N]; double w[N],dp[N]; while(scanf("%d %d",&n,&m),n+m) { for(int i=1;i<=m;i++) { scanf("%d %lf",&c[i],&w[i]); } memset(dp,0,sizeof(dp)); for(int i=1;i<=m;i++) { for(int j=n;j>=c[i];j--) { dp[j]=max(dp[j],(1-(1-dp[j-c[i]])*(1-w[i]))); } } printf("%.1lf%%\n",dp[n]*100); } return 0; }
I NEED A OFFER!---hdu1203(01背包)
标签:
原文地址:http://www.cnblogs.com/linliu/p/5136840.html