Classic smart question: Train Coal Transportation

Source: Internet
Author: User
Tags rounds

The question is described as follows:

You are a coal boss. You have mined 3000 tons of coal in the mining area and need to transport it to the market for sale. there are 1000 kilometers from your mining area to the market, there is a coal-powered train in your hand. This train can transport a maximum of 1000 tons of coal at a time, and the train consumes one ton of coal per kilometer. Q: How can I transport the most coal to the market?

=============-.-==============









Thinking time









=============-.-==============

From the question, it is easy to see that there is a contradiction: the distance is 1000 kilometers, and a maximum of 1000 tons of coal can be transported, obviously not directly. If you go directly, not only will there be no coal to deliver, but there will be a lot of coal left in the original place. Therefore, we must use all the coal in the original place. Therefore, a transfer station must be set up. Then the question becomes how many transfer stations are needed, where are they located?

First, let's start with a simple process. First, set up a transfer station in the middle, that is, 500 km, to see if there is any effect. In order to achieve the goal of "transporting the most coal to the end", there must be no coal in the original place. Therefore, we must take out all the coal at the beginning. Because there is a total of 3000 tons of coal, we need to move 1000 tons for the first time and leave 500 at 500 km, but in order to be able to go back, all 500 tons of coal must be taken back. So the first trip wasted 1000 tons of effort. The same is true for the second 1000 tons. During the third transportation of 1000 tons, because there was no need to go back, the current situation is that the train had 500 tons of coal, 500 kilometers away from the terminal. Therefore, such a transfer station is useless, and the final coal that can be transported is 0.

However, the above ideas are still enlightening. From the question, we can see that a transfer station must be set up, and from the failure of the transport method, we can see that the purpose of setting up a transfer station is to keep all the coal close to the destination. Although it is more expensive to run back and forth, the total amount of coal is very surplus, and the volume of transportation is limited, so we need to "run back and forth" to keep the coal close to the end.

We should also make it clear that if there are N transfer stations on the road, we should first run back and forth between the start station and the first transfer station until the Empty coal is transported, and then run back and forth between the first and second transfer stations, till the coal is removed. Cross-Site Coal Transportation is not optimal, and cross-site transportation is the same or even more wasteful. Then a perfect test plan will come out:Since it is not cross-site, you can directly observe the current status. If a transfer station is added between the train and the terminal, it will be better. Otherwise, you can directly go.

So we will set the transfer station at 400 kilometers? The first round trip consumes 800 tons, while the transfer station leaves 200 tons. The second round-trip consumes 800, and the transfer station leaves 200 tons. The third stop came directly, with 600 tons left at the transfer station. Now the train is 600 kilometers away from the terminal, and the transfer station of the train has 1000 tons of coal. Start directly, and finally successfully deliver 400 tons to the terminal.

In the first place, because the distance was far enough, it was obvious that we had to run back and forth to make all the coal closer to the end point. When the distance was not too far away, we had to make a choice: to run back and forth to carry all the coal, or take as much coal as possible at one time. Set the distance to X kilometers. The current coal volume is r tons.

When R is less than or equal to 1000, it is obvious that it is going directly.
When 1000 <r <= 2000, take 3 trips (past, back, past), it is easy to write the formula: (1000-2x) + (R-1000)-x> 1000-x, solve x <(R-1000)/2 back to run better, otherwise take 1000 tons directly.
When 2000 <r <= 3000, to take 5 trips, the solution when x <(R-1000)/4 back to run, otherwise take 1000 tons directly.

When we set up a transfer station every 250 meters, the final coal that can be transported was 500 tons. This was the best result I thought at the time.


At that time, my head was not transferred. It took a long time to find a solution bigger than 500. Intuitively, it is not a good idea to guess the location and quantity of a transfer station so as to gradually obtain the optimal solution. We know that it is too expensive to run back and forth, so we will not run back and forth if we can run back and forth. The initial coal volume is 3000 tons. The first round must be 5 rounds, with X kilometers running. X is obviously <500 (refer to the first idea above), so the remaining distance after the first round is> = 500. Therefore, if there is a better solution, the second round will certainly not go directly. At least there will be a second transfer station. The idea at this time is very critical. We need to determine the remaining coal volume after one round before we can make the optimal choice in turn.

① Assume that the remaining coal is less than 1000 tons after one round. The second round goes directly. The equation is as follows:

Y = MAX [3000-5x-(1000-x)] = 2000-4x

Because 3000-5x <= 1000, x> = 400, so y <= 400

② Assume that the remaining coal volume is greater than 2000 after one round

In this case, the first round is rather short. We know that when the result is more than 2000 tons, the intermediate process is the same for multiple times. For example, the first round took 100 kilometers and the remaining coal was 2500 tons, which is the same as taking two 50 kilometers or four 25 kilometers respectively. If there are more than 2000 tons of trains remaining, we still need to carry 5 more trains, so we will merge them into one segment, the same. So we do not consider the situation ②

③ Assume that the remaining coal volume after one round is between 1000 tons and 2000 tons.

Through the analysis in Case 2, we found that there are only ① and ③ two cases. We also found that when R is in the same section, the results are the same for multiple times. So ③ we continue to transport coal until the remaining 1000 tons of coal, and then directly go.

This seems to be three rounds.

The first round of the combined operation of 2000 tons of coal to the transfer station, consuming 1000 tons, because 5x = 1000, so the first round took 200 meters.

The second round of combined operation of 1000 tons of coal to the transfer station, consuming 1000 tons of coal, because 3x = 1000, so the second round took 1000/3 meters.

In the third round, 1000 tons of coal were taken directly. After the previous transportation, the remaining 1000-200-1000/3 = 1400/3 km, so the final remaining 1000-1400/3 = 1600/3 ≈ 533 tons.

The idea may be a bit messy -.-

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.