1000 bottles of liquid 10 white mice interview questions answer, 1000 bottles of questions answer

Source: Internet
Author: User

1000 bottles of liquid 10 white mice interview questions answer, 1000 bottles of questions answer

Reprinted please indicate the source: http://blog.csdn.net/xiaojimanman/article/details/45917689

Http://www.llwjy.com/blogdetail/1cee085f07d9f8b59c35df384b30fccc.html

The personal blog website has been launched. Its website is www.llwjy.com ~ Thank you ~
Bytes -------------------------------------------------------------------------------------------------

In the last blog, I left a white mouse interview question. Here is the final answer.


Problem description

There are 1000 bottles of liquid (normal, non-toxic), but due to staff mistakes, the poison is dropped into one of the bottles, we can't tell from the appearance and smell that the drug was contaminated. We only know that the toxic period of this drug is 7 days, and there are 10 mice in the laboratory, how can I know which bottle is contaminated only after 7 days?


Solution

1) We will number 1000 bottles of liquid 1 ~ 1000, and then convert the number into a 10-bit binary, for example, 1 is 0000000001;

2) numbers 10 mice 1 ~ 10;

3) give the binary number of the liquid to the corresponding mouse, for example, the liquid number is 1111100000, that is 1 ~ No. 5 mice do not drink this bottle of liquid, 6 ~ On the 10th, the white mouse drank this bottle of liquid;

4) after one week, observe the death of the mouse ~ No. 5 dead mice, 6 ~ When the mice were alive on the 10th, the binary code of the toxic bottle of liquid was 0000011111;

5) convert the binary code obtained in Step 4 to decimal. Here is the 31st, so we can infer that the liquid numbered 31 is contaminated.


Bytes -------------------------------------------------------------------------------------------------

Small benefits

Bytes -------------------------------------------------------------------------------------------------

I have already launched the Lucene case development course at geek College (now the first course is available ~

Lesson 1: Lucene Overview

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.