标签:des style color io java for strong 数据 sp
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 16505 Accepted Submission(s): 6584
#include <stdio.h> #include <string.h> #include <algorithm> using namespace std; double min(double a,double b) { if(a>b) return b; return a; } int main() { int n,m,i,j,a[10010]; double dp[10010],b[10010]; while(~scanf("%d %d",&n,&m),n+m) { for(i=1;i<=m;i++) { scanf("%d %lf",&a[i],&b[i]); b[i]=1-b[i];//拿不到的概率 } for(i=0;i<=n;i++) dp[i]=1.0;//最大概率为1 for(i=1;i<=m;i++) { for(j=n;j>=a[i];j--) dp[j]=min(dp[j],dp[j-a[i]]*b[i]); } printf("%.1lf%%\n",(1-dp[n])*100); } return 0; }
HDU 1203 I NEED A OFFER (01背包)
标签:des style color io java for strong 数据 sp
原文地址:http://www.cnblogs.com/caterpillarofharvard/p/4021103.html