标签:
#include <iostream> #include <cstring> #include <cstdio> #define MAX 10007 #define min(a,b) (a)<(b)?(a):(b) using namespace std; struct job{ int cost; double probability; }; int main() { int n,m; job j[MAX]; double dp[MAX]; while(cin>>n>>m && m+n) { for(int i = 0;i <= n;i++) dp[i] = 1; for(int i = 1;i <= m;i++) cin>>j[i].cost>>j[i].probability; for(int i = 1;i <= m;i++) for(int k = n;k >= j[i].cost;k--) dp[k] = min(dp[k],dp[k-j[i].cost]*(1-j[i].probability)); printf("%.1lf%%\n",(1-dp[n])*100); } return 0; }
标签:
原文地址:http://www.cnblogs.com/immortal-worm/p/5149474.html