文件名称:Huffman
-
所属分类:
- 标签属性:
- 上传时间:2016-05-11
-
文件大小:19kb
-
已下载:0次
-
提 供 者:
-
相关连接:无下载说明:别用迅雷下载,失败请重下,重下不扣分!
介绍说明--下载内容来自于网络,使用问题请自行百度
修理牧场:农夫要修理牧场的一段栅栏,他测量了栅栏,发现需要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
但是农夫自己没有锯子,请人锯木头的酬金跟这段木头的长度成正比。为简单起见,不妨就设酬金等于所锯木头的长度。例如,要将长度为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/Huffman.cbp
Huffman/Huffman.depend
Huffman/Huffman.layout
Huffman/bin/
Huffman/bin/Debug/
Huffman/bin/Debug/Huffman.exe
Huffman/main.cpp
Huffman/obj/
Huffman/obj/Debug/
Huffman/obj/Debug/main.o
Huffman/Huffman.cbp
Huffman/Huffman.depend
Huffman/Huffman.layout
Huffman/bin/
Huffman/bin/Debug/
Huffman/bin/Debug/Huffman.exe
Huffman/main.cpp
Huffman/obj/
Huffman/obj/Debug/
Huffman/obj/Debug/main.o
本网站为编程资源及源代码搜集、介绍的搜索网站,版权归原作者所有! 粤ICP备11031372号
1999-2046 搜珍网 All Rights Reserved.