Location:
Search - acm 22
Search list
Description: acm pku 2236题,代码加解题思路-acm pku 2236 title, code plus problem-solving ideas
Platform: |
Size: 1024 |
Author: lyd |
Hits:
Description: 22. 切木头
成绩: 10 / 折扣: 0.9
背景
人们需要把一跟很长的木头切成几段,有一家名为 Analog Cutting Machinery (ACM) 的公司正在经营这一业务。他们根据切割前木头的长度来收费,木头越长、收费越高,并且每切割一次就收一次费。
显而易见,在这里切割木头时,不同的切割顺序就会产生不同的价钱。譬如一跟 10 米长的木头,需要在 2、4、7 米处切开。如果顺序在这三个位置切割,需要的费用是 10 8 6 = 24,因为木头原始长度为 10 米,切掉两米剩 8 米,在四米处切掉剩 6 米。如果按照 4、2、7 的顺序来切割,花费就是 10 4 6 = 20。
任务
你的老板有很多木材要切割,现在他希望你能够帮他找到最便宜的切割方式。
输入
一次输入可能包含多组数据。每一组数据的第一行是木材的长度L (L<=1000),如果为 0 则表示输入结束。每组数据的第二行是要切割的次数 N (N<=50),第三行则是切割的位置Ci (0<Ci<L)。以上数据均为整数。
输出
针对每一组输入,输出切割这段木头的最小费用。
-22. Cutting wood
Results: 10/Discount: 0.9
Background
People need to put a cut into the wood with long paragraphs, there is a company called Analog Cutting Machinery (ACM) of the company is operating the business. Them according to the length of wood before cutting charges, the longer the wood, the higher the fees, and each time to receive a fee cut.
Obviously, cutting wood in here, different order will produce different cutting price. For instance, one with 10 meters of wood, you need to cut the 2,4,7 meters. If the sequence of cutting in these three locations, the cost of required 1086 = 24, because the original length of 10 meters of wood, cut two meters 8 meters left, cut off the remaining four meters 6 meters. If the cut in accordance with the order 4,2,7, cost is 1046 = 20.
Task
Your boss has a lot of wood to be cut, and now he wants you to help him find the cheapest way of cutting.
Input
One input may contain multiple sets of data. The first line of each set of dat
Platform: |
Size: 1024 |
Author: a123 |
Hits: