杭电2602 Bone Collector 【01背包】】的更多相关文章

Bone Collector Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 60469    Accepted Submission(s): 25209 Problem Description Many years ago , in Teddy’s hometown there was a man who was called “Bo…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=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 collect…
Bone Collector Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 27413    Accepted Submission(s): 11154 Problem Description Many years ago , in Teddy's hometown there was a man who was called "Bo…
Bone Collector Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 65099    Accepted Submission(s): 27122 Problem Description Many years ago , in Teddy’s hometown there was a man who was called “Bon…
这种01背包的裸题,本来是不想写解题报告的.但是鉴于还没写过背包的解题报告.于是来一发. 这个真的是裸的01背包. 代码: #include <iostream> #include <cstdio> using namespace std; #define N 1007 int c[N],w[N],dp[N]; int main() { int t,i,n,V,v; scanf("%d",&t); while(t--) { scanf("%d%…
题意:给定一个体积,和一些物品的价值和体积,问你最大的价值. 析:最基础的01背包,dp[i] 表示体积 i 时最大价值. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include <string> #include <cstdlib> #include <cmath> #include <iostream>…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2602 解题思路:给出一个容量为V的包,以及n个物品,每一个物品的耗费的费用记作c[i](即该物品的体积),每一个物品的价值记作w[i], 我们用 f[v]来表示一个容量为v的包的总价值,这样最后我们只需要输出f[V]就能得出结果 则对于第i个物品,它可以放入背包,此时背包的容量变为v-c[i],背包的总价值变为f[v-c[i]]+w[i], 它也可以不放入背包,此时背包的容量还是v,背包的总价值不变…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2602 水题啊水题 还给我WA了好多次 因为我在j<w[i]的时候状态没有下传.. #include <cstdio> #include <algorithm> #include <cstring> using namespace std; typedef long long LL; typedef pair<int,int> PII; #define PB…
解题思路:对于01背包的状态转移方程式f[v]=max(f[v],f[v-c[i]+w[i]]);其实01背包记录了每一个装法的背包值,但是在01背包中我们通常求的是最优解, 即为取的是f[v],f[v-c[i]]+w[i]中的最大值,但是现在要求第k大的值,我们就分别用两个数组保留f[v]的前k个值,f[v-c[i]]+w[i]的前k个值,再将这两个数组合并,取第k名. 即f的数组会增加一维. http://blog.csdn.net/lulipeng_cpp/article/details/…
Problem Description 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 volu…
本文出自:http://blog.csdn.net/svitter 题意:典型到不能再典型的01背包.给了我一遍AC的快感. //============================================================================ // Name : 2602.cpp // Author : vit // Version : // Copyright : Your copyright notice // Description : Hello…
Bone Collector Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 32768/32768K (Java/Other) Total Submission(s) : 21   Accepted Submission(s) : 6 Problem Description Many years ago , in Teddy’s hometown there was a man who was called “Bone Collec…
本文来源于:http://blog.csdn.net/svitter 题意:典型到不能再典型的01背包.给了我一遍AC的快感. //============================================================================ // Name : 2602.cpp // Author : vit // Version : // Copyright : Your copyright notice // Description : Hello…
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…
原题代号:HDU 2602 原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=2602 原题描述: Problem Description 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…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2602 这是做的第一道01背包的题目.题目的大意是有n个物品,体积为v的背包.不断的放入物品,当然物品有各自的体积和价值.在不超过总体积v的情况下,问能够达到的最大价值.并且物品是一个一个放入的.最后若有剩余的体积也不会填满. 刚开始是用贪心做的.将价值与体积的比值设定为一个值,即单位价值.然后按照单位价值排序,挨个取物品,考虑到了体积为0的情况,就将单位价值设定为无穷大.但是这样做并不能保证最优解.…
2017-09-03 15:42:20 writer:pprp 01背包裸题,直接用一维阵列的做法就可以了 /* @theme: 01 背包问题 - 一维阵列 hdu 2602 @writer:pprp @begin:15:34 @end:15:42 @declare:最基本的01背包问题 POJ 3624 @error:最后取得是dp[M]不是 dp[M-1],然后注意数据范围dp的数据范围是M的范围 @date:2017/9/3 */ #include <iostream> #includ…
Problem Description 电子科大本部食堂的饭卡有一种非常诡异的设计,即在购买之前推断剩余金额. 假设购买一个商品之前,卡上的剩余金额大于或等于5元,就一定能够购买成功(即使购买后卡上剩余金额为负),否则无法购买(即使金额足够).所以大家都希望尽量使卡上的剩余金额最少. 某天,食堂中有n种菜出售.每种菜可购买一次. 已知每种菜的价格以及卡上的剩余金额,问最少可使卡上的剩余金额为多少.   Input 多组数据.对于每组数据: 第一行为正整数n.表示菜的数量.n<=1000. 第二行…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2602 思路分析:该问题为经典的0-1背包问题:假设状态dp[i][v]表示前i件物品恰放入一个容量为v的背包可以获得的最大价值,则可以推导出dp递推公式 dp[i][v] = Max{dp[i-1][v], dp[i-1][v – c[i]] + w[i]}:c[i]表示第i件物品的容量,w[i]表示第i件物品的价值:该动态规划问题每个阶段的决策为是否要 选择第i件物品放入背包中,如果不选择第i件物…
首先输入一个数字代表有n个样例 接下来的三行 第一行输入n  和  v,代表n块骨头,背包体积容量为v. 第二行输入n块骨头的价值 第三行输入n块骨头的体积 问可获得最大的价值为多少 核心:关键在于dp[j]=max(dp[j],dp[j-w[i]]+v[i]) 的状态转移!! 背包最多能装下题目中所给的骨头,如体积为10的背包能装下体积分别为5和4的体积一块, 但最后其实背包还剩余了体积为1的位置没有讨论,则通过 j-- 进行剩余补充讨论. 在体积不断减小的同事每次都对目前这个这个体积(目前状…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2602 Bone Collector Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 54132    Accepted Submission(s): 22670 Problem Description Many years ago , in…
HDOJ(HDU).2602 Bone Collector (DP 01背包) 题意分析 01背包的裸题 #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #define nmax 1005 using namespace std; int v[nmax],w[nmax],dp[nmax]; int main() { //freopen("in…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=2602 Bone Collector Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 77450    Accepted Submission(s): 32095 Problem Description Many years ago , in…
题目链接:pid=2602">HDU 2602 Bone Collector Bone Collector Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 28903    Accepted Submission(s): 11789 Problem Description Many years ago , in Teddy's h…
http://acm.hdu.edu.cn/showproblem.php?pid=2602 Bone Collector Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 32408    Accepted Submission(s): 13329 Problem Description Many years ago , in Tedd…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2602 Problem Description 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…
Problem Description 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 volum…
Bone Collector Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 39532    Accepted Submission(s): 16385 Problem Description Many years ago , in Teddy's hometown there was a man who was called "Bo…
Bone Collector http://acm.hdu.edu.cn/showproblem.php?pid=2602 Problem Description 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…
意甲冠军:给出的数量和袋骨骼的数,然后给每块骨骼的价格值和音量.寻求袋最多可容纳骨骼价格值 难度;这个问题是最基本的01背包称号,不知道的话,推荐看<背包9说话> AC by SWS 主题链接 http://acm.hdu.edu.cn/showproblem.php?pid=2602 代码: #include<stdio.h> #include<string.h> typedef struct{ int w, v; }str; str s[1005]; int dp[…