1000 Apple distribution problems

Source: Internet
Author: User

Old Wang has 1000 apples in boxes numbered 1-10. No matter how many apples a customer needs to buy, he can always follow the appropriate boxes numbered, the total number of apples in these boxes is exactly the same as the customer's needs. How did Old Wang do that?

Tip: this interesting question is about binary sensitivity.

 

Answer: We can use the binary method to allocate the number of apples in each box.

Box No.: 1 2 3 4 5 6 7 8 9 10

Apple count: 1 2 4 8 16 32 64 128 256 489 (512-23)

Why is the last box 489? Because the total number of apples is 1000. If the last box is 512, the total number will exceed 1000, and the total number will be 489, only in this way can the customer be freely combined as long as the customer needs to satisfy the customer

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.