Poj post 1160

Source: Internet
Author: User

The question is to give v villages and take P as the post office, which requires the minimum distance from each village to the post office.

First, consider that there is only one post office, no matter how you put the post office or the minimum situation is always at the point.

Consider the case where p> 1:

Assuming that the post offices in the P-1 have been selected, the last one is minimized by selecting one of the remaining unselected villages.

There is a recursive formula: M [v] [p] = min {M [I] [P-1] + dis [I + 1] [v]}

M [I] [P-1] indicates the minimum distance and the P-1 post office in the previous village. The p-1 <= I <= V;

Dis [I + 1] [v] indicates selecting a village from I + 1 to minimize the distance (I + 1, v) from the village to the village, that is, to resolve

Only one post office is under consideration (it must have been in the middle ).

Note: The post office that is added later is always placed at the midpoint of (I + 1, V). Dis [I + 1] [v] indicates (I + 1, v) to the sum of the centers.

At first, I thought that I + 1 was not necessarily closest to the newly added post office, then Min [I] [P-1] + dis [I + 1] [v] is not the smallest sum.

However, although the sum obtained in this way is not the smallest, the smallest sum will be obtained in the next solution process, so the result will not be affected.

Poj post 1160

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.