文件名称:Huffman

  • 所属分类:
  • 其他小程序
  • 资源属性:
  • [C/C++] [源码]
  • 上传时间:
  • 2016-05-12
  • 文件大小:
  • 19kb
  • 下载次数:
  • 2次
  • 提 供 者:
  • 圈*
  • 相关连接:
  • 下载说明:
  • 别用迅雷下载,失败请重下,重下不扣分!

介绍说明--下载内容均来自于网络,请自行研究使用

修理牧场:农夫要修理牧场的一段栅栏,他测量了栅栏,发现需要N块木头,每块木头长度为整数Li个长度单位,于是他购买了一条很长的、能锯成N块的木头,即该木头的长度是Li的总和。

但是农夫自己没有锯子,请人锯木头的酬金跟这段木头的长度成正比。为简单起见,不妨就设酬金等于所锯木头的长度。例如,要将长度为20的木头锯成长度为8、7和5的三段,第一次锯木头花费20,将木头锯成12和8;第二次锯木头花费12,将长度为12的木头锯成7和5,总花费为32。如果第一次将木头锯成15和5,则第二次锯木头花费15,总花费为35(大于32)。

请编写程序帮助农夫计算将木头锯成N块的最少花费。

首先输入一个正整数N(N≤104),表示要将木头锯成N块。接着给出N个正整数Li(Li≤50),表示每段木块的长度。输出一个整数,即将木头锯成N块的最少花费。-Repair Ranch: Ranch farmer to repair a section of the fence, he measured the fence, found necessary N block of wood, each piece of wood is an integer of length L i of length units, so he bought a very long, can sawn N wood block, ie the length of the wood is the sum of L i. But he did not saw the farmer, asked people to sawing wood proportional to the length of this remuneration with wood. For simplicity, may wish to set remuneration equal to the length of sawing wood. For example, to a length of sawn wood 20 of a length of three sections 8,7 and 5, the first 20 takes sawing wood, the wood sawn 8 and 12 the second sawing wood takes 12, a length of 12 wood sawn 7 and 5, the total cost of 32. If the first 5 to 15 and sawn wood, sawing wood spent the second 15, the total cost of 35 (greater than 32). Please write a program to help farmers calculate sawn wood will spend a minimum of N blocks. First, enter a positive integer N (N≤10 4), N represents sawn wood to block. Then given N positiv
(系统自动生成,下载前可以参看下载内容)

下载文件列表





Huffman

.......\Huffman.cbp

.......\Huffman.depend

.......\Huffman.layout

.......\bin

.......\...\Debug

.......\...\.....\Huffman.exe

.......\main.cpp

.......\obj

.......\...\Debug

.......\...\.....\main.o

相关说明

  • 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
  • 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度更多...
  • 请直接用浏览器下载本站内容,不要使用迅雷之类的下载软件,用WinRAR最新版进行解压.
  • 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
  • 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
  • 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.

相关评论

暂无评论内容.

发表评论

*主  题:
*内  容:
*验 证 码:

源码中国 www.ymcn.org