标签:
跟小偷那道差不多,水~~~
Description
Input
Output
Sample Input
Sample Output
Hint
You should use printf("%%") to print a ‘%‘.
#include<cstdio> #include<algorithm> #include<cstring> #include<cstdlib> using namespace std; int main(){ int n, m,w[10000]; double v[10000],dp[10000]; while(~scanf("%d%d", &n,&m)){ for(int i = 0; i < 10000; i++) dp[i] = 1; if(m==0&&n==0) continue; for(int i = 0; i < m; i++) scanf("%d%lf",&w[i],&v[i]); for(int i = 0; i < m ; i++){ v[i] = 1 - v[i]; } for(int i = 0; i < m; i++){ for(int j = n; j >= w[i]; j--){ dp[j] = min(dp[j], dp[j-w[i]] * v[i]); } } printf("%.1lf%%\n",(1-dp[n])*100); } return 0; }
标签:
原文地址:http://www.cnblogs.com/zero-begin/p/4313529.html