标签:动态规划
不懂得见blog.csdn.net/lihaogegehuting/article/details/38067455
代码如下:
#include<stdio.h> struct node { int cost; double wei; } a[10004]; double min(double a,double b) { return a>b? b:a;} int main() { int i,j,n,m; double dp[10004]; while(~scanf("%d%d",&n,&m),n+m) { for(i=0;i<10004;i++) dp[i]=1.0; for(i=0;i<m;i++) scanf("%d%lf",&a[i].cost,&a[i].wei); for(i=0;i<m;i++) for(j=n;j>=a[i].cost;j--) dp[j]=min(dp[j],dp[j-a[i].cost]*(1-a[i].wei)); printf("%.1lf%%\n",(1-dp[n])*100); } return 0; }
hdu 1203 I NEED A OFFER!,布布扣,bubuko.com
标签:动态规划
原文地址:http://blog.csdn.net/lihaogegehuting/article/details/38083875