标签:des style blog http color io os ar java
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 16758 Accepted Submission(s): 6677
#include<iostream> #include<cstring> #include<cstdio> using namespace std; #define min(a,b) ((a)<(b)?(a):(b)) #define N 10010 int w[N]; double dp[N]; double v[N]; int main() { int n,s,i,j; while(scanf("%d%d",&s,&n),n||s) { for(i=1;i<=n;i++) { scanf("%d%lf",&w[i],&v[i]); v[i]=1-v[i]; } for(i=0;i<=N;i++) //从0开始啊,白贡献WA { dp[i]=1; } for(i=1;i<=n;i++) { for(j=s;j>=w[i];j--) { dp[j]=min(dp[j],dp[j-w[i]]*v[i]); } } printf("%.1f%%\n",(1-dp[s])*100); } return 0; }
标签:des style blog http color io os ar java
原文地址:http://www.cnblogs.com/hate13/p/4051913.html