觉得浮夸了四年,漠然发现原来是浮躁了四年!

摘要: Problem DescriptionI have N precious stones, and plan to use K of them to make a necklace for my mother, but she won't accept a necklace which is too heavy. Given the value and the weight of each precious stone, please help me find out the most valuable necklace my mother will accept.InputThe fi 阅读全文
posted @ 2013-04-25 20:47 heat nan 阅读(200) 评论(0) 推荐(0)
摘要: 二分查找是基于分治思想的一种算法,所谓分治思想就是将一些规模很大难于直接解决的问题,缩小为一个较小的问题就很容易解决的思想,(当然它的子问题仍可以继续分解为相同的子问题)。归结为一句话就是:“以大化小,各个击破,分而治之,组合取果”。二分查找作为一种高效的查找算法,是解决一些有序序列查找的不二之选。但他的缺点也就是使用于有序的数组,有一定的局限性。但二分在一些高效的程序设计中往往被用作优化的利器。因此,熟练应用二分查找是必须的。二分查找的实现:比如有一列数从1到100,已经排好序,我们要查找25,按照传统的逐个遍历,需要查找25次,而采用二分查找的方法,首先那25和这组数列的中间的数做比较50 阅读全文
posted @ 2013-04-25 09:20 heat nan 阅读(1126) 评论(1) 推荐(3)