- 博客(45)
- 资源 (5)
- 收藏
- 关注
原创 背包系列第六篇----完全背包(求解最大价值的个数)
一:问题完全背包问题描述:一个容量为V的背包。现在有N种物品,每种物品有无数个,每种物品的体积是C1,C2,…,Cn,对应的每种的价值是W1,W2,…,Wn.。试问,在不超过背包容量的情况下,物品装入背包的最大价值?和第三篇一样,我们来求出最大价值的个数。二:分析理解我们设置num[ i ][ j ]二维数组来表示dp[ i ][ j ]的方案数。1.dp[ i ][ j
2016-04-30 15:06:18 787
原创 背包系列第五篇----完全背包(求解最大价值时背包的物品)
一:问题完全背包问题描述:一个容量为V的背包。现在有N种物品,每种物品有无数个,每种物品的体积是C1,C2,…,Cn,对应的每种的价值是W1,W2,…,Wn.。试问,在不超过背包容量的情况下,物品装入背包的最大价值?在此基础上,如何求出背包内的物品?二:分析理解和背包系列的第二篇相似,需要设置一个path[ ][ ]保存路径。三:代码#include #include
2016-04-30 11:39:53 1558
原创 数据结构与算法系列----学习数据结构与算法前你需要知道的
数据结构教科书上开篇就是“什么是数据结构?”,这里我也就不多说了,没意思。我总是把“数据结构”和“算法”这两个词语看做是一样的(个人而言哈),我们倒不如说说算法能干什么,学习数据结构能干什么?不知道大家有没有看过印度大片《三傻大闹宝莱坞》,里边的主人公在上课(应该是机械课之类的)的时候被一位老师叫起回答一个问题,“说下机器的含义”,当时这位主人公就简单的说了句,“能省力的就是机器”。现
2016-04-28 11:45:38 2498
原创 背包系列第四篇----完全背包(求解最大价值)
一:问题完全背包问题描述:一个容量为V的背包。现在有N种物品,每种物品有无数个,每种物品的体积是C1,C2,…,Cn,对应的每种的价值是W1,W2,…,Wn.。试问,在不超过背包容量的情况下,物品装入背包的最大价值?二:分析理解先来看下完全背包和01背包的区别,我们再来看下什么是01背包?01背包问题描述:一个容量为V的背包。现在有N种物品,每种物品只有一个,每种物品的体积是C1,
2016-04-27 19:40:00 1840
原创 背包系列第三篇----01背包(求解最大价值的个数)
一:问题01背包问题描述:一个容量为V的背包。现在有N种物品,每种只有一个物品,每种物品的体积是C1,C2,…,Cn,对应的每种的价值是W1,W2,…,Wn.。试问,在不超过背包容量的情况下,物品装入背包的最大价值?什么叫最大价值的个数?当我们求出一个背包问题的最大价值时,这个最大价值是固定的,但是背包里的物品可能不一样。二:分析理解我们设置num[ i ][ j ]二维数
2016-04-27 16:29:07 3200
原创 背包系列第二篇----01背包(求解最大价值时背包的物品)
一:问题经过第一篇的学习,我们学会求解最大价值,而此篇是在求出最大价值的同时,也要求出背包内有哪么物品?这是一个记录路径问题。二:分析理解我们设置一个path[][]二维数组记录路径。这不是很难,看代码应该能看懂。三:代码#include #include using namespace std;#define N 6 #define V 10
2016-04-27 15:43:03 2285
原创 hdu2844 Coins --多重背包
原题链接: http://acm.hdu.edu.cn/showproblem.php?pid=2844一:原题内容Problem DescriptionWhuacmers use coins.They have coins of value A1,A2,A3...An Silverland dollar. One day Hibix opened purse an
2016-04-25 17:14:29 1018
原创 hdu1114 Piggy-Bank --完全背包
原题链接: http://acm.hdu.edu.cn/showproblem.php?pid=1114一:原题内容Problem DescriptionBefore ACM can do anything, a budget must be prepared and the necessary financial support obtained. The mai
2016-04-25 15:22:08 717
原创 hdu2191 悼念512汶川大地震遇难同胞——珍惜现在,感恩生活 --多重背包
原题链接: http://acm.hdu.edu.cn/showproblem.php?pid=2191一:原题内容Problem Description急!灾区的食物依然短缺!为了挽救灾区同胞的生命,心系灾区同胞的你准备自己采购一些粮食支援灾区,现在假设你一共有资金n元,而市场有m种大米,每种大米都是袋装产品,其价格不等,并且只能整袋购买。请问:你用有限的
2016-04-24 20:01:41 760
原创 hdu2159 FATE --二维完全背包
原题链接: http://acm.hdu.edu.cn/showproblem.php?pid=2159一:原题内容Problem Description最近xhd正在玩一款叫做FATE的游戏,为了得到极品装备,xhd在不停的杀怪做任务。久而久之xhd开始对杀怪产生的厌恶感,但又不得不通过杀怪来升完这最后一级。现在的问题是,xhd升掉最后一级还需n的经验值,xhd还
2016-04-24 17:35:11 601
原创 hdu1864 最大报销额 --01背包
原题链接: http://acm.hdu.edu.cn/showproblem.php?pid=1864一:原题内容Problem Description现有一笔经费可以报销一定额度的发票。允许报销的发票类型包括买图书(A类)、文具(B类)、差旅(C类),要求每张发票的总额不得超过1000元,每张发票上,单项物品的价值不得超过600元。现请你编写程序,在给出的一堆发
2016-04-22 18:32:40 878
原创 hdu2955 Robberies --01背包
原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=2955一:原题内容Problem DescriptionThe aspiring Roy the Robber has seen a lot of American movies, and knows that the bad guys usually gets caught
2016-04-21 19:12:51 501
原创 hdu1171 Big Event in HDU --01背包
原题链接: http://acm.hdu.edu.cn/showproblem.php?pid=1171一:原题内容Problem DescriptionNowadays, we all know that Computer College is the biggest department in HDU. But, maybe you don't know tha
2016-04-21 12:32:28 626
原创 hdu2639 Bone Collector II--01背包K优解
原题链接: http://acm.hdu.edu.cn/showproblem.php?pid=2639一:原题内容Problem DescriptionThe title of this problem is familiar,isn't it?yeah,if you had took part in the "Rookie Cup" competition,yo
2016-04-20 15:59:54 606
原创 hdu2602 Bone Collector--01背包
原题链接: http://acm.hdu.edu.cn/showproblem.php?pid=2602一:原题内容Problem DescriptionMany years ago , in Teddy’s hometown there was a man who was called “Bone Collector”. This man like to coll
2016-04-20 12:33:48 620
原创 hdu2647 Reward--拓扑排序
原题链接: http://acm.hdu.edu.cn/showproblem.php?pid=2647一:原题内容Problem DescriptionDandelion's uncle is a boss of a factory. As the spring festival is coming , he wants to distribute rewards
2016-04-19 12:55:45 704
原创 hdu1285 & hdu4857 --拓扑排序
原题链接: http://acm.hdu.edu.cn/showproblem.php?pid=1285一:原题内容Problem Description有N个比赛队(1 Input输入有若干组,每组中的第一行为二个数N(1Output给出一个符合要求的排名。输出时队伍号之间有空格,最后一名后面没有空格。其他说明:符合条件的排名可能不
2016-04-19 10:17:50 657
原创 求第k小的数
题目是这样的,一个无序的数组让你找出第k小的元素,我当时看到这道题的时候也像很多人一样都是按普通的思维,先排序然后取第K个,但是当数组非常大的时候,效率不高,那有没有简单的方法了,其实我们早就学过,只是我们不善于思考和变通。很多人刚开始非常热衷于各种排序算法只是了解却没深究,这个题目的复杂度是O(n),原理就是快速排序里面的划分算法。分析:快速排序选择一个base(一般是第一个数)对数组进
2016-04-18 16:08:52 1215
原创 hdu5154 Harry and Magical Computer--拓扑排序
原题链接: http://acm.hdu.edu.cn/showproblem.php?pid=5154一:原题内容Problem DescriptionIn reward of being yearly outstanding magic student, Harry gets a magical computer. When the computer begin
2016-04-17 15:24:18 800
原创 hdu1128 Self Numbers--哈希表水题
原题链接: http://acm.hdu.edu.cn/showproblem.php?pid=1128一:原题内容Problem DescriptionIn 1949 the Indian mathematician D.R. Kaprekar discovered a class of numbers called self-numbers. For any p
2016-04-16 18:37:10 1282
原创 hdu1014 Uniform Generator--哈希表水题
原题链接: http://acm.hdu.edu.cn/showproblem.php?pid=1014一:原题内容Problem DescriptionComputer simulations often require random numbers. One way to generate pseudo-random numbers is via a funct
2016-04-15 22:33:51 1002
原创 hdu4287 Intelligent IME--哈希表
原题链接: http://acm.hdu.edu.cn/showproblem.php?pid=4287一:原题内容Problem Description We all use cell phone today. And we must be familiar with the intelligent English input method on the cel
2016-04-14 19:34:39 691
原创 hdu3833 YY's new problem--哈希表
原题链接: http://acm.hdu.edu.cn/showproblem.php?pid=3833一:原题内容Problem DescriptionGiven a permutation P of 1 to N, YY wants to know whether there exists such three elements P[i1], P[i2], P[
2016-04-14 16:14:42 716
原创 poj2002 Squares--哈希表
原题链接:http://poj.org/problem?id=2002一:原题内容DescriptionA square is a 4-sided polygon whose sides have equal length and adjacent sides form 90-degree angles. It is also a polygon such that r
2016-04-14 13:03:36 742
原创 hdu2473 Junk-Mail Filter-并查集(删除)
原题链接: http://acm.hdu.edu.cn/showproblem.php?pid=2473一:原题内容Problem DescriptionRecognizing junk mails is a tough task. The method used here consists of two steps:1) Extract the common
2016-04-13 16:16:40 907
原创 hdu1811 Rank of Tetris --拓扑排序&并查集
原题链接: http://acm.hdu.edu.cn/showproblem.php?pid=1811一:原题内容Problem Description自从Lele开发了Rating系统,他的Tetris事业更是如虎添翼,不久他遍把这个游戏推向了全球。为了更好的符合那些爱好者的喜好,Lele又想了一个新点子:他将制作一个全球Tetris高手排行榜,定时更新
2016-04-12 13:08:54 755
原创 全排列的实现方法--递归&字典序
一:背景全排列在很多笔试都有应用,是一个很常见的算法,关于这类的题目变化很多。这种算法的得到基于以下的分析思路。 给定一个具有n个元素的集合(n>=1),要求输出这个集合中元素的所有可能的排列。例如:给定{1,2,3},全排列为3!个,即:{1,2,3},{1,3,2}{2,1,3},{2,3,1}{3,1,2},{3,2,1}下来分别说下递归法,John
2016-04-11 15:33:25 17386 2
原创 hdu3038 How Many Answers Are Wrong--种类并查集
原题链接: http://acm.hdu.edu.cn/showproblem.php?pid=3038一:原题内容Problem DescriptionTT and FF are ... friends. Uh... very very good friends -________-bFF is a bad boy, he is always wooi
2016-04-10 13:45:01 705
原创 hdu3635 Dragon Balls--并查集
原题链接: http://acm.hdu.edu.cn/showproblem.php?pid=3635一:原题内容Problem DescriptionFive hundred years later, the number of dragon balls will increase unexpectedly, so it's too difficult for Mo
2016-04-10 11:19:56 552
原创 hdu3172 Virtual Friends--并查集
原题链接: http://acm.hdu.edu.cn/showproblem.php?pid=3172一:原题内容Problem DescriptionThese days, you can do all sorts of things online. For example, you can use various websites to make virtua
2016-04-08 20:36:44 564
原创 hdu3047 Zjnu Stadium--带权并查集
原题链接: http://acm.hdu.edu.cn/showproblem.php?pid=3047一:原题内容Problem DescriptionIn 12th Zhejiang College Students Games 2007, there was a new stadium built in Zhejiang Normal University.
2016-04-08 12:49:55 619
转载 C/C++ 语言中的表达式求值 -- 裘宗燕(绝对好文章!!!)
经常可以在一些讨论组里看到下面的提问:“谁知道下面C语句给n赋什么值?”m = 1; n = m+++m++;最近有位不相识的朋友发email给我,问为什么在某个C++系统里,下面表达式打印出两个4,而不是4和5:a = 4; cout C++ 不是规定 要弄清这些,需要理解的一个问题是:如果程序里某处修改了一个变量(通过赋值、增量/减量操作等),什么时候从该变量能够取
2016-04-06 21:50:03 1348
原创 hdu1856 More is better--并查集
原题链接: http://acm.hdu.edu.cn/showproblem.php?pid=1856一:原题内容Problem DescriptionMr Wang wants some boys to help him with a project. Because the project is rather complex,the more boys c
2016-04-06 13:57:07 572
原创 hdu1829 A Bug's Life --分组并查集
原题链接: http://acm.hdu.edu.cn/showproblem.php?pid=1829一:原题内容Problem DescriptionBackground Professor Hopper is researching the sexual behavior of a rare species of bugs. He assumes that
2016-04-06 12:40:57 534
原创 hdu1325 Is It A Tree?--并查集
原题链接: http://acm.hdu.edu.cn/showproblem.php?pid=1325一:原题内容Problem DescriptionA tree is a well-known data structure that is either empty (null, void, nothing) or is a set of one or more
2016-04-05 15:00:21 592
原创 hdu1272 小希的迷宫--并查集
原题链接: http://acm.hdu.edu.cn/showproblem.php?pid=1272一:原题内容Problem Description上次Gardon的迷宫城堡小希玩了很久(见Problem B),现在她也想设计一个迷宫让Gardon来走。但是她设计迷宫的思路不一样,首先她认为所有的通道都应该是双向连通的,就是说如果有一个通道连通了房间A和B,那
2016-04-05 12:35:24 590
原创 hdu3666 THE MATRIX PROBLEM--单源最短路径&差分约束
原题链接: http://acm.hdu.edu.cn/showproblem.php?pid=3666一:原题内容Problem DescriptionYou have been given a matrix CN*M, each element E of CN*M is positive and no more than 1000, The problem is
2016-04-04 14:36:26 593
原创 hdu1534 Schedule Problem--单源最短路径&差分约束
原题链接: http://acm.hdu.edu.cn/showproblem.php?pid=1534一:原题内容Problem DescriptionA project can be divided into several parts. Each part should be completed continuously. This means if a pa
2016-04-02 19:04:16 703
原创 hdu3440 House Man--单源最短路径&差分约束
原题链接: http://acm.hdu.edu.cn/showproblem.php?pid=3440一:原题内容Problem DescriptionIn Fuzhou, there is a crazy super man. He can’t fly, but he could jump from housetop to housetop. Today he
2016-04-02 13:07:23 562
Unity圣典.chm
2015-12-05
Unity3D中的线性插值Lerp()函数解析
2015-12-03
Sublime Text2汉化包
2015-11-30
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人