标签:-- nbsp 维数 limit 分数 题意 sub 考试 inpu
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 28496 Accepted Submission(s): 11569
1 #include<iostream> 2 #include<cstdio> 3 using namespace std; 4 double max(double a, double b) 5 { 6 if (a > b) 7 return a; 8 return b; 9 } 10 int main() 11 { 12 int m, n, i, j, z[10005]; 13 double dp[10005], d[10005]; 14 while (scanf("%d%d",&n,&m)!=EOF,n+m) 15 { 16 for (i = 1;i <= m;i++) 17 { 18 cin >> z[i] >> d[i]; 19 d[i] = d[i] * 100; 20 } 21 for (i = 0;i <= n;i++) 22 dp[i] = 0; 23 for (i = 1;i <= m;i++) 24 for (j = n;j >= z[i];j--) 25 dp[j] = max(dp[j], dp[j - z[i]] + d[i] - dp[j - z[i]] * d[i]/100); 26 printf("%.1f%%\n", dp[n]); 27 } 28 return 0; 29 }
这题因为double精度那个问题卡了好久,希望有大大解释解释这是什么情况。
标签:-- nbsp 维数 limit 分数 题意 sub 考试 inpu
原文地址:http://www.cnblogs.com/forever-snow/p/7101184.html