文章分类 -  动态规划算法模板

摘要:http://acm.hdu.edu.cn/showproblem.php?pid=3732Sample Input5 20go 5 8think 3 7big 7 4read 2 6write 3 5Sample Output15☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆#include <iostream>#include <cstdio>using namespace std;const int W = 11;const int V = 11;const int M = 10010;int goods[W][V],dp[M],cap,n;void zeroOnePack 阅读全文
posted @ 2011-05-05 18:43 Pengchao Bai 阅读(190) 评论(0) 推荐(0)
摘要:/**背包状态转移方程:*if(weight[i]>j) dp[i][j]=dp[i-1][j];*else dp[i][j] = max(dp[i-1][j],dp[i-1][j-weight[i]]+value[i]);*/#include <iostream>using namespace std;const int N = 1000;const int M = 10000;int w[N],v[N],dp[M];int max(int a,int b){return a>b?a:b;}int main(){int n,m,i,j;cin>>n> 阅读全文
posted @ 2011-04-27 09:31 Pengchao Bai 阅读(142) 评论(0) 推荐(0)