标签:des style blog http java color
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 10933 Accepted Submission(s): 4049
1 #include <iostream> 2 #include <stdio.h> 3 #include <string.h> 4 #include <math.h> 5 using namespace std; 6 #define eps 0.0000001 7 int main() 8 { 9 int t,b[200],i,n,j; 10 double p,a[200],dp[11000]; 11 scanf("%d",&t); 12 while(t--) 13 { 14 for(i=0;i<11000;i++)dp[i]=2; 15 scanf("%lf%d",&p,&n); 16 for(i=0;i<n;i++) 17 scanf("%d%lf",&b[i],&a[i]); 18 dp[0]=0; 19 for(i=0;i<n;i++) 20 for(j=11000-1;j>=0;j--) 21 { 22 if(j-b[i]>=0) 23 dp[j]=min(dp[j-b[i]]*(1-a[i])+dp[j-b[i]]*a[i]+(1-dp[j-b[i]])*a[i],dp[j]); 24 } 25 26 for(i=11000-1;i>0;i--) 27 { 28 if(dp[i]<=p)break; 29 //if(i==2)cout<<fabs(dp[i]-p)<<endl; 30 } 31 cout<<i<<endl; 32 } 33 }
Robberies hdu 2955 01背包,布布扣,bubuko.com
标签:des style blog http java color
原文地址:http://www.cnblogs.com/ERKE/p/3839899.html