至少得反面是一个没有 所以方程为 max(dp[j], 1-(1-dp[j-v[i]])*(1-c[i]))
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
double dp[10050], c[10005];
int v[10010];
int main()
{
int n, m;
while(scanf("%d %d", &n, &m) != EOF)
{
if(n+m == 0) break;
for(int i = 0; i < m; i++) scanf("%d %lf", &v[i], &c[i]);
memset(dp, 0, sizeof(dp));
for(int i = 0; i < m; i++)
for(int j = n; j >= v[i]; j--)
dp[j] = max(dp[j], 1-(1-dp[j-v[i]])*(1-c[i]));
dp[n] = dp[n]*100;
printf("%.1lf%%\n", dp[n]);
}
}
hdu1203 01背包
最新推荐文章于 2019-06-13 07:56:43 发布