题目链接:Frobenius 思路:想了很久还是没转过弯来. 递推. 初始化vis[0] = 1,每次有四种方法扩展,这样能扩展到所有能被表示的数.上界的判定,如果一万以内的数都能被表示,那以后的数肯定就都能被表示. /* HDU 1681 递推.if (vis[i] == 1) {vis[i+a] = vis[i+b] = vis[i+c] = vis[i+d] = 1; } 可以得到所有0~10^6以内不能被表示的数.然后,判断最大是不是<10^6,只要循环到一百万零一万就可以了. 因为四个…
一个完全背包,数组两百万,暴力可过 #include<iostream> #include<cstdio> #include<cstring> using namespace std; #define maxn 2000010 int dp[maxn]; int main() { ]; scanf("%d",&t); while(t--) { ;i < ;i++) scanf("%d",&w[i]); mem…
Problem Description Before ACM can do anything, a budget must be prepared and the necessary financial support obtained. The main income for this action comes from Irreversibly Bound Money (IBM). The idea behind is simple. Whenever some ACM member has…
分析:每种菜仅仅可以购买一次,但是低于5元不可消费,求剩余金额的最小值问题..其实也就是最接近5元(>=5)时, 购买还没有买过的蔡中最大值问题,当然还有一些临界情况 1.当余额充足时,可以随意购买菜,即∑p - max_p +5 <= m  时,re = m - ∑p 2.当余额不充足时,有一种特殊情况,不能消费的情况,即m<5时    re = m; 3.余额不足时,只能购买部分菜,转化成01背包问题,找出最接近最接近5的值, 状态转换方程: f[0][P] = true;f[0][…
HDU 3127 WHUgirls(完全背包) http://acm.hdu.edu.cn/showproblem.php? pid=3127 题意: 如今有一块X*Y的矩形布条, 然后有n种规格的x[i]*y[i]的小布条, 每种布条能够卖出val[i]的价值. 问你原始的X*Y布条最多能卖多少价值?   当中每次分割布条仅仅能水平或垂直的切, 且一刀究竟. 分析: 本题看起来比較麻烦, 可是搞懂原理后还是非常easy的. 把当前还剩余的矩形布条看成容量, 那么我们就是再这有限的容量里面要找出…
Piggy-Bank Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 32061 Accepted Submission(s): 15931 Problem Description Before ACM can do anything, a budget must be prepared and the necessary financial…
Piggy-Bank Before ACM can do anything, a budget must be prepared and the necessary financial support obtained. The main income for this action comes from Irreversibly Bound Money (IBM). The idea behind is simple. Whenever some ACM member has any smal…
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…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1114 思路:求出存钱罐装全部装满情况下硬币的最小数量,即求出硬币的最小价值.转换为最小背包的问题. #include<iostream> #include<cstdio> #include<cstring> using namespace std; ; int dp[INF],val[INF],we[INF]; int main(void) { int t,n,i,j,m,…
http://acm.hdu.edu.cn/showproblem.php?pid=3535 题意:有n组工作,T时间,每个工作组中有m个工作,改组分类是s,s是0是组内至少要做一件,是1时最多做一件,2时随意,每项工作的描述是花费的时间和获得的快乐值,求在T时间内可获的最大快乐值. memset放错位置了,折腾老半天. 分组混合背包,有的取一件或不取,有的随意,有的最少一个 分三种情况讨论 s==0 考虑前面取过时这次取或不取,前一组取过时这次取或不取 s==1 考虑前一组取过时这次取或不取…