Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 28178 Accepted Submission(s): 11425
1 //2017-05-24 2 #include <cstdio> 3 #include <cstring> 4 #include <iostream> 5 #include <algorithm> 6 7 using namespace std; 8 9 const int N = 10010; 10 double dp[N]; 11 12 int main() 13 { 14 int n, m, C; 15 double W; 16 while(cin>>m>>n){ 17 if(!n && !m)break; 18 for(int i = 0; i <= m; i++)dp[i] = 1.0; 19 for(int i = 1; i <= n; i++){ 20 cin>>C>>W; 21 for(int j = m; j >= C; j--){ 22 dp[j] = min(dp[j], dp[j-C]*(1-W)); 23 } 24 } 25 printf("%.1lf%%\n", (1-dp[m])*100); 26 } 27 28 return 0; 29 }
原文:http://www.cnblogs.com/Penn000/p/6901197.html