标签:
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 18408 Accepted Submission(s):
7368
#include<stdio.h> #include<string.h> #include<algorithm> using namespace std; #define INF 0x3f3f3f double dp[10010]; int n,m; struct sch { int a; double b; }s[10010]; void solve() { for(int i=0;i<m;i++) { for(int j=n;j>=s[i].a;j--) { dp[j]=min(dp[j],dp[j-s[i].a]*(1-s[i].b)); } } printf("%.1lf%%\n",(1-dp[n])*100); } int main() { while(scanf("%d%d",&n,&m)!=EOF&&(n+m))//这里写成while(scanf("%d%d",&n,&m)!=EOF&&n&&m)就WA { for(int i=0;i<=n;i++) dp[i]=1; //memset(dp,1,sizeof(dp));//用这个初始化的时候不对!!! for(int i=0;i<m;i++) { scanf("%d%lf",&s[i].a,&s[i].b); } solve(); } return 0; } //既要费用不超过n,又要概率最小(求至少收到一份offer的概率,就是求 //1-最小概率)
标签:
原文地址:http://www.cnblogs.com/qianyanwanyu--/p/4423581.html