Split gold bars

Source: Internet
Author: User

One Classic questions:
You let the workers work for you for 7 days, the return of the worker is a gold bar. Gold bars are divided into 7 connected segments, and you have to give them a piece of gold at the end of the day, and if you only have to break the gold bars two times, how do you pay your workers?

Second, the idea:
1. Gold bars can be changed, such as the workers have a piece of gold bars, pay the day can be paid by 2 paragraph to change workers, can not say that the workers get gold bars immediately took to spend, then no play
2. Gold bars are only allowed to break 2 times, that is to say, only 3 pieces of gold bar
3. Because workers receive daily wages are increasing, that is to say workers will get 1, 2, 3 ... 7 Pieces of gold bar
4. Therefore, this problem can be translated into: How to combine 3 numbers, you can get 1, 2, 3 ... 7 and these 3 numbers any one of which may be here on a certain day, or where the worker is, if we use 1 to indicate that a certain number is in my place, with 0 means not here, according to mathematical logic, this is exactly the problem of a binary number expression:
These 3 numbers are:
1 1 1
We found that the 3-bit binary can express the number is 0 ~ 111, that is, 0 ~ 7, just meet the requirements of the topic, then the simple, 3-bit binary is the length of a piece of gold bar, the bit is 1, that this section of gold bars in my place, for 0 is paid to the workers.
That 3 bits corresponds to the binary number is: 1, 2, 4
The payment method is just a truth-table:
Day One: 110, give the workers 1 pieces of gold bars
Day two: 101, give the workers 2 pieces of gold bars, take back 1 pieces of gold bars
Day three: 100, 1 and 2 bars are given to the workers
Fourth day: 011, give workers 4 pieces of gold bars, take back 1 paragraphs and 2 sections of gold bars
Fifth day: 010, give the worker 1 pieces of gold bar
Sixth day: 001, give workers 2 pieces of gold bars, take back 1 pieces of gold bars
Day seventh: 000, gold bars are given to workers.

Third, expansion
After figuring out the nature of the problem, we extend it further, such as adding a bit, will become 1111, can express 0~15, then the topic can also be changed for a worker for you to work for 15 days, gold bars can only be divided into 4 paragraphs, ask how to divide? If you look at the above ideas of friends, I believe that should be able to answer it soon.

Split gold bars

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.