动态规划 背包问题 poj 1837 Balance
2017-08-20 17:25
405 查看
#include<cstdio> #include<cstring> #include<iostream> using namespace std; int dp[25][15010]; int main() { int n,g; int c[30]; int w[30]; cin>>n>>g; for(int i=1;i<=n;++i){ cin>>c[i]; } for(int i=1;i<=g;++i){ cin>>w[i]; } memset(dp,0,sizeof(dp)); dp[0][7500]=1; for(int i=1;i<=g;++i){ for(int j=0;j<=15000;++j){ if(dp[i-1][j]){ for(int k=1;k<=n;++k){ dp[i][j+c[k]*w[i]]+=dp[i-1][j]; } } } } cout<<dp[g][7500]<<endl; }
相关文章推荐
- POJ 1837:Balance:动态规划_背包问题变形
- POJ 1837 Balance(动态规划之背包问题)
- 【POJ】1837 Balance 【背包问题】
- POJ 1837 Balance [动态规划——完全背包]
- POJ 1837 Balance(01背包 动态规划)
- POJ 1837 二维背包 天平平衡问题
- POJ 1837 Balance 背包变形
- poj1837--Balance(dp:天平问题)
- poj1837 Balance (二维费用背包&&分组背包)
- poj 1837 Balance (01背包变形)
- POJ 1837 Balance(DP动态规划)
- POJ 1276 Cash Machine -- 动态规划(背包问题)
- 0-1背包问题入门小结 动态规划(DP)经典题目 POJ324 POJ1276
- 0-1背包问题入门小结 动态规划(DP)经典题目 POJ324 POJ1276
- POJ 题目1837 Balance(分组背包)
- poj 1837 Balance (貌似二维背包,带负数)
- poj 1837 Balance(背包)
- POJ 1837 Balance (动态规划)
- POJ 1276 Cash Machine -- 动态规划(背包问题)
- 【动态规划/多重背包问题】POJ1014-Dividing