Java written question: Camel water and car oil problem. (My own opinion, hope everyone good, correct me)

Source: Internet
Author: User

A businessman with Donkey Yun Carrot 3000 to sell, desert long 1000 kilometers, donkey a maximum camel 1000, but each walk a kilometer to eat a carrot, ask the businessman can sell how many carrots.

Solution: Set to transport X meters to return to the transport, then transported to X 3 times, X at the Radish 3 (1000-2x);

where x must be less than 500.

The rest of the way: 1000-x, assuming that the middle does not stop a trip: Then 3 (1000-2x) >=1000, x<=1000/3; to reach the destination of up to 1000/3 left;

Suppose two times: 1000-x is greater than 500 and cannot be back 2 times. Loft

If the remaining points 2 times, then from the know must be at the set Y stop, you can see X to y at least 2 times, y to the destination 1 trip, 3 (1000-2x) >=2000 then X=1000/6, 2 (1000-2y) =1000,y=1000/ 2 So the arrival destination remains: 1000-X-Y=1000-1000/6-1000/2=1000/3;

If divided 4 times, the last time must be a trip, then the penultimate second time is two times, analogy for the first time for 4 times, impossible, so up to 3 times to go.

So the answer is 1000/3.

Change the subject

The journey is 1000, the origin of the carrot is countless, asked to arrive at the destination of 1000, at least how much carrot consumption?

Suppose 3 times (average distance):

Last: (1000-2/3*1000)/(1000/3) + 1 trips = 2

Countdown two times: (2000-2/3*1000)/(1000/3) +1=5

Countdown three times: 13

So 13000 root.

Suppose N times

Last an= (1/n)/(1-2/n) +1=1/(n-2) +1 so n can only be 3

The following is a discussion of the non-average distance (time relationship, next!) )

Java written question: Camel water and car oil problem. (My own opinion, hope everyone good, correct me)

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.