poj 1837 Balance 二维背包
来源:互联网 发布:stl源码剖析第二章 编辑:程序博客网 时间:2024/05/17 22:56
砝码重量25,个数20,天平长度15
上限 15*25*20==7500
#include <cstdio>
#include <iostream>#include <cmath>
#include <queue>
#include <algorithm>
#include <cstring>
using namespace std;
const int inf = 0x3f3f3f3f;
const int MAXN = 25;
int L[MAXN], W[MAXN];
int dp[MAXN][15000];
int main()
{
int n, m;
scanf("%d %d", &n, &m);
for(int i=1; i<=n; ++i)
scanf("%d", &L[i]);
for(int i=1; i<=m; ++i)
scanf("%d", &W[i]);
memset(dp, 0, sizeof(dp));
dp[0][7500]=1;
for(int i=1;i<=m;++i)
{
for(int j=0;j<=15000;++j)
{
for(int k=1;k<=n;++k)
{
dp[i][j+W[i]*L[k]]+=dp[i-1][j];
}
}
}
printf("%d\n", dp[m][7500]);
return 0;
}
0 0
- poj 1837 Balance 二维背包
- poj 1837 Balance 二维费用背包
- POJ 1837 Balance DP 二维背包
- poj 1837 Balance(背包)
- POJ 1837 Balance(二维dp)
- poj 1837 Balance(01背包)
- poj 1837 Balance--01背包
- poj 1837 Balance 01背包
- poj 1837 Balance (01背包)
- poj 1837 Balance(背包)
- POJ 1837 Balance / 分组背包
- poj 1837 Balance (01背包)
- POJ 1837 Balance 背包变形
- POJ 1837 Balance(01背包)
- POJ 1837 Balance 背包dp
- Poj 1837 Balance(背包)
- POJ 1837 Balance (01背包)
- POJ 1837-Balance(01背包)
- Android 怎么把imageview 转为Bitmap
- 写给Android开发者的混淆使用手册
- 剑指Offer系列-面试题51:数组中重复的数字
- 统计学总结之Bias(偏差),Error(误差),和Variance(方差)的区别
- Codeforces 653C Bear and Up-Down【暴力+思维】题目还不错~
- poj 1837 Balance 二维背包
- 关系代数中的除法运算(转载)
- 详解EditText输入监听TextWatcher
- 打印日期
- render_template() takes exactly 1 argument
- 垃圾归垃圾,渣滓归渣滓。尘土归尘土
- 欢迎使用CSDN-markdown编辑器
- 画图游戏(博弈论)
- 树莓派开发系列教程3——树莓派rasp-config配置