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