poj 1837分组背包
来源:互联网 发布:linux挂载盘到home好吗 编辑:程序博客网 时间:2024/05/20 04:31
参考了别人的思路 点击打开链接
N种距离钩子,m个重量,每个重量放不同的钩子就是一个分组
分组背包:
#include<iostream> #include <string> #include<vector> #include<algorithm> #include<set> #include<fstream>#include<cmath> using namespace std; #define lch(i) ((i)<<1) #define rch(i) ((i)<<1|1) #define sqr(i) ((i)*(i)) #define pii pair<int,int> #define mp make_pair #define FOR(i,b,e) for(int i=b;i<=e;i++) #define ms(a) memset(a,0,sizeof(a)) const int maxnum =25;int n,m;int w[maxnum],h[maxnum];int dp[maxnum][15005];int main() { scanf("%d%d",&n,&m);FOR(i,1,n){scanf("%d",&h[i]);}FOR(i,1,m){scanf("%d",&w[i]);}dp[0][7500]=1;FOR(i,1,m){FOR(j,0,15000){FOR(k,1,n){int last = j-w[i]*h[k];if(last>=0&&last<=15000&&dp[i-1][last])dp[i][j]+=dp[i-1][last];}}}printf("%d\n",dp[m][7500]);return 0;}
0 0
- poj 1837分组背包
- 分组背包 poj 1837
- POJ 1837 Balance / 分组背包
- poj 1837 Balance 分组背包
- Poj 1837 Balance(经典分组背包)
- POJ 题目1837 Balance(分组背包)
- poj 3046 分组背包
- poj 1712 分组背包
- poj 3211 Washing Clothes 分组01背包
- POJ 1947 树形 DP + 分组背包
- POJ 1018 Communication System (分组背包)
- Ant Counting (poj 3046 分组背包)
- poj 3211 Washing Cloth 分组背包
- 分组01背包 POJ Washing Clothes
- POJ 1947 树形DP(分组背包)
- poj 3211 Washing Clothes 分组背包?
- poj 1155 树形dp+分组背包
- 01分组背包-poj 3211 Washing Clothes
- 终端简单的命令 -- 增删改查
- HDU 2063 过山车(二部图)
- 湖南省第七届大学生计算机程序设计竞赛 多连块拼图
- 体绘制的原理和Raycasting的实现
- 黑马程序员——java基础---反射
- poj 1837分组背包
- ios开发系列之系统通讯录的相关操作
- HDOJ 2156 分数矩阵 (数学题)
- GPU Raycasting的两种实现方法
- heat内部异常如何转换为HTTP异常返回给客户端
- 代码生活
- multiset容器基本操作
- Android内存管理知识
- mysql事务处理、加锁用法与实例详解