文件名称:hebingguozi
-
所属分类:
- 标签属性:
- 上传时间:2012-11-16
-
文件大小:751byte
-
已下载:0次
-
提 供 者:
-
相关连接:无下载说明:别用迅雷下载,失败请重下,重下不扣分!
介绍说明--下载内容来自于网络,使用问题请自行百度
在一个果园里,多多已经将所有的果子打了下来,而且按果子的不同种类分成了不同的堆。多多决定把所有的果子合成一堆。 每一次合并,多多可以把两堆果子合并到一起,消耗的体力等于两堆果子的重量之和。可以看出,所有的果子经过n-1次合并之后,就只剩下一堆了。多多在合并果子时总共消耗的体力等于每次合并所耗体力之和。 因为还要花大力气把这些果子搬回家,所以多多在合并果子时要尽可能地节省体力。假定每个果子重量都为1,并且已知果子的种类数和每种果子的数目,你的任务是设计出合并的次序方案,使多多耗费的体力最少,并输出这个最小的体力耗费值。 例如有3种果子,数目依次为1,2,9。可以先将1、2堆合并,新堆数目为3,耗费体力为3。接着,将新堆与原先的第三堆合并,又得到新的堆,数目为12,耗费体力为12。所以多多总共耗费体力=3+12=15。可以证明15为最小的体力耗费值-In an orchard, a lot has shot down all the fruit, and of different types of fruit into a different pile. Decided to put all the fruit of a lot of synthetic pile. Each merger, a lot can be merged together two piles of fruit, equal to two piles of physical consumption of fruit and weight. It can be seen, all the fruit through the n-1 times after the merger, on the left a pile of. When a lot of fruit in the combined strength equal to the total consumption of each of the merger and the physical consumption. Because these also make great efforts to move the fruit home, so when a lot of fruit in the merger as much as possible to save energy. Assume that each fruit weight is 1, and the number of species known to fruit and the number of each type of fruit, your task is to design a combined order of programs, so a lot of physical least cost and physical output of the minimum cost value. For example, there are three kinds of fruit, followed by the number 1,2,9. 1,2 heap can be first merged, the
(系统自动生成,下载前可以参看下载内容)
下载文件列表
合并果子.txt
hebingguozi.cpp
hebingguozi.cpp
本网站为编程资源及源代码搜集、介绍的搜索网站,版权归原作者所有! 粤ICP备11031372号
1999-2046 搜珍网 All Rights Reserved.