文章分类 - 动态规划算法模板
摘要: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
阅读全文
摘要:/**背包状态转移方程:*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>
阅读全文

浙公网安备 33010602011771号