Big Event in HDU Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 23728    Accepted Submission(s): 8363 Problem Description Nowadays, we all know that Computer College is the biggest department…
背包问题 以下代码 n是物品个数,m是背包容积 物品价值和重量int v[maxn],w[maxn]; 01背包 模板 for(int i = 0; i < n; i++) { for(int j = m; j >= w[i]; j--) { f[j]=max(f[j],f[j-w[i]]+v[i]); } } 完全背包 模板 for(int i=1; i<=n; i++) { for(int j=w[i]; j<=m; j++) //和01背包的唯一区别 { f[j]=max(f…
题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=1171 题意 老师有一个属性:价值(value).在学院里的老师共有n种价值,每一种价值value对应着m个老师,说明这m个老师的价值都为value.现在要将这些老师从人数上平分成两个院系,并且希望平分后两个院系老师的总价值A和B应尽可能地相等,求A和B的值(A>=B). 思路 由于每种老师的个数是有限的,所以使用多重背包解决.由于测试数据不是很严格,所以使用01背包也可以通过. 代码 01背包: #…
Big Event in HDU Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 51181    Accepted Submission(s): 17486 Problem DescriptionNowadays, we all know that Computer College is the biggest department…
Big Event in HDU Problem Description Nowadays, we all know that Computer College is the biggest department in HDU. But, maybe you don't know that Computer College had ever been split into Computer College and Software College in 2002.The splitting is…
Big Event in HDU Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 51789    Accepted Submission(s): 17690 Problem Description Nowadays, we all know that Computer College is the biggest department…
题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=2191 思路 由于每种大米可能不止一袋,所以是多重背包问题,可以直接使用解决多重背包问题的方法,也可以将多重背包转化为01背包后求解. 代码 01背包: #include <algorithm> #include <iostream> #include <cstring> #include <cstdio> using namespace std; * + ; i…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1963 //多重背包 #include <cstdio> #include <cstring> #include <iostream> using namespace std; + ; #define N 15 long long dp[maxn], ans; int c[N], w[N], V; void Pack(int C, int W) { for(int i = C…
链接:http://acm.hdu.edu.cn/showproblem.php?pid=2844 思路:多重背包 , dp[i] ,容量为i的背包最多能凑到多少容量,如果dp[i] = i,那么代表这个数能凑出来,ans+1: 实现代码: #include<bits/stdc++.h> using namespace std; ; int lis[M],dp[M],a[M],c[M]; int main() { int n,m,idx; while(cin>>n>>m…
http://acm.hdu.edu.cn/showproblem.php?pid=1059 Dividing Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 29901    Accepted Submission(s): 8501 Problem Description Marsha and Bill own a collection…