• hdu1203


    这个题是0,1背包

    #include <iostream>
    #include <algorithm>
    #include <cstdio>
    #include <cstring>
    #include <cstdlib>
    using namespace std;
    const int maxn = 1e4+10;
    double dp[maxn];
    int w[maxn];
    double v[maxn];
    int main()
    {
        int n,m,i,j;
        while(scanf("%d%d",&n,&m) && n+m)
        {
            memset(dp, 0, sizeof(dp));
            for(i=0; i < m; ++i)
            {
                scanf("%d %lf",w+i,v+i);
                v[i] = 1.0-v[i];
            }
            for(j=0; j <= n; ++j)
            {
                dp[j] = 1.0;
            }
            for(i=0; i<m; ++i)
            {
                for(j=n ; j>=w[i]; --j)
                {
                    dp[j] = min(dp[j],dp[j-w[i]]*v[i]);
                }
            }
            printf("%.1f%%
    ",(1.0-dp[n])*100);
        }
    }
  • 相关阅读:
    find
    fdisk
    falcon-eye
    ethtools
    e2fsck
    dpkg
    declare
    df
    debconf-utils
    区块链从零开始做开发(0):hyperledger Fabric2.3安装
  • 原文地址:https://www.cnblogs.com/mltang/p/8725326.html
Copyright © 2020-2023  润新知