dp重拾-01背包--HDU 2602】的更多相关文章

Many years ago , in Teddy’s hometown there was a man who was called “Bone Collector”. This man like to collect varies of bones , such as dog’s , cow’s , also he went to the grave …The bone collector had a big bag with a volume of V ,and along his tri…
减肥记 湫湫给了你每日食物清单,上面描述了当天她想吃的每种食物能带给她的幸福程度,以及会增加的卡路里量. Input 输入包含多组测试用例. 每组数据以一个整数n开始,表示每天的食物清单有n种食物. 接下来n行,每行两个整数a和b,其中a表示这种食物可以带给湫湫的幸福值(数值越大,越幸福),b表示湫湫吃这种食物会吸收的卡路里量. 最后是一个整数m,表示湫湫一天吸收的卡路里不能超过m. [Technical Specification] 1. 1 <= n <= 100 2. 0 <= a…
1.hdu 2126 Buy the souvenirs 题意:给出若干个纪念品的价格,求在能购买的纪念品的数目最大的情况下的购买方案. 思路:01背包+记录方案. #include<iostream> #include<cstdio> #include<cstring> using namespace std; ; ; int cnt[maxw]; int dp[maxw]; int p[maxn]; int main() { int t; scanf("%…
题目链接:https://vjudge.net/contest/103424#problem/I 转载于:>>>大牛博客 题目大意: 有 n 个货物,并且知道了每个货物的重量,每次用载重量分别为c1,c2的火车装载,问最少需要运送多少次可以将货物运完. 解题分析: 物品个数最多是10个,可以用0和1分别表示物品是否被选中运送 假设有3个物品,那么可以用001表示当前这一次选择将第3个物品运走 那么,所有的状态可以用0~2^n-1对应的二进制数表示出来 对于上述每一种状态,选择其中可以一次…
显然,n<=20, m<=4 的数据范围一眼爆搜. 直接搜索一下不用哪4个砝码,再做一遍01背包即可. 可能是本人太菜鸡,01背包部分调了半天QAQ-- #include<cstdio> #include<algorithm> #include<cstring> #include<iostream> using namespace std; const int maxn = 2002; int ans,n,target,sumv, w[30];…
传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1561 The more, The Better Time Limit: 6000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 9590    Accepted Submission(s): 5568 Problem Description ACboy很喜欢玩一种战略游戏,…
题目描述 设有 1g1g1g . 2g2g2g . 3g3g3g . 5g5g5g . 10g10g10g . 20g20g20g 的砝码各若干枚(其总重 ≤1000 \le 1000≤1000 ), 输入输出格式 输入格式: 输入方式: a1,a2,a3,a4,a5,a6a_1 , a_2 ,a_3 , a_4 , a_5 ,a_6a1​,a2​,a3​,a4​,a5​,a6​ (表示 1g1g1g 砝码有 a1a_1a1​ 个, 2g2g2g 砝码有 a2a_2a2​ 个,…, 20g20g…
P1025小飞侠的游园方案 请 登录 后递交 标签:[显示标签] 描述 菜虫:你的题目是--我们的情报组织探听到敌人的重要将领--小飞侠星期天会邀他的灵儿妹妹到公园去玩.公园里有很多娱乐项目,可并不是每一项他们都喜欢,所以他们对每一项都进行了"喜欢度"的评分.因为小飞侠也是一个了不起的角色,所以他一定会选择在有限时间内的最好的方案.现在要你做的就是找出在规定时间内他们选择哪几项不同的活动可以使其"喜欢度"之和达到最大,据此我们就可以知道他会在哪些地方出现,从而在那里…
# include <stdio.h> # include <stdlib.h> # include <string.h> # define max(x,y) x>y?x:y; ];//价值 ];//重量 ][]; int main() { int n,m; while(scanf("%d%d",&m,&n)!=EOF) { memset(dp,,sizeof(dp));//初始化 ; i<=n; i++) scanf(&…
题目传送门:P2871 [USACO07DEC]手链Charm Bracelet 题目描述 Bessie has gone to the mall's jewelry store and spies a charm bracelet. Of course, she'd like to fill it with the best charms possible from the N (1 ≤ N ≤ 3,402) available charms. Each charm i in the supp…