背包模板
来源:互联网 发布:乐山电视台网络电视 编辑:程序博客网 时间:2024/06/06 02:49
#include <iostream>#include <algorithm>#include <string.h>#include <cmath>#include <stdio.h>#include <vector>#include <map>#include <queue>#include <utility>typedef long long ll;using namespace std;const int MAX = 100000000;int a[MAX], dp[MAX];void Zero_packpage(const int& volume, const int& value, const int& cost) { for (int i = volume; i >= value; --i) dp[i] = max(dp[i], dp[i-cost] + value);}void Compelet_packpage(const int& volume, const int& value, const int& cost) { for (int i = cost; i <= volume; ++i) dp[i] = max(dp[i], dp[i-cost] + value);}void Multip_package(const int& volume, const int& value, const int& cost, const int& many) { if (many * cost >= volume) Compelet_packpage(volume, value, cost); else { int k = volume, i = 1; while (k > i) { Zero_packpage(volume, value*i, cost*i); k -= i; i <<= 1; } Zero_packpage(volume, value*k, value*k); } return;}int main(){ }
0 0
- 【背包模板】
- 背包模板
- 背包模板
- 背包模板
- 背包模板
- 背包模板
- 背包模板
- 背包模板
- 01背包,完全背包,模板
- 完全背包多重背包模板
- 01背包,完全背包模板
- 01背包、完全背包、多重背包模板
- 模板-01背包-完全背包-多重背包
- 01背包、完全背包、多重背包模板
- 01背包+完全背包+多重背包模板
- 01背包 完全背包 多重背包模板
- 01背包模板和完全背包模板
- 部分背包问题模板
- Map 遍历
- ssh安装及免密登录使用说明
- bzoj1294: [SCOI2009]围豆豆Bean
- 【Fltk】Fltk1.3.3+VS2015 "X11/Xlocale.h"错误
- 递推递归——M
- 背包模板
- Live555中RTP包的打包与发送过程分析1
- 网页中调起AndroidAPP并传递数据
- 关于神杀的高耦合的讨论
- 一道不错的面试题
- 腾讯云教你一个只有99行代码的JS流程框架
- Linux wc命令
- python的一些小程序
- Java笔记——面向对象