Ultraviolet (a) 10003-cutting sticks

Source: Internet
Author: User

Question Link:Click here ~

Question Analysis:

Give a wooden rod with a length of L and give n places to be cut. You need to complete the task at the minimum cost. How is the cost calculated? That is, the length of the current wooden rod is used.

Algorithm analysis:

The memory process can reduce a lot of time. The essence of this question is the interval DP. The original question is the typical issue of stone merge. If it is hard to understand, you can think about the flody model in graph theory.

State transition equation: DP [I] [J] = min (DP [I] [J], solve (I, K) + solve (K, J) + Len [J]-len [I]) is essentially a flody model conversion.

When applied to the memory-based search, there are generally two termination conditions. One is available according to the requirements of the question, and the other is to avoid repeated computation and directly use the previous results.

First, if (I + 1 = J) return 0; that is, only one merging interval exists.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.