Interesting questions about the binary and triplicate formats

Source: Internet
Author: User

Http://blog.csdn.net/zhuxiaoyang2000/article/details/6091767

 

 

It's not difficult to think about several issues first. You guys should be able to kill in seconds:

 

1. Xiao Ming is an apple seller. Xiao Hong once bought n (n <1024) apples from Xiao Ming. Xiao Ming needs to count n apples to Xiao Hong every time. Alas, it is too troublesome. So James came up with a way: he divided the apple into 10 bags, and no matter how many apples he bought, he could give the whole bag to Xiaohong. Q: How do I allocate apples to various bags?

 

2. there are 16 solutions, and only one of them is toxic. This toxic solution will change color when mixed with another reagent A, while other non-toxic solutions will not change color when mixed with. It is known that an experiment takes one hour. Because a mixed reaction requires one test tube, how many test tubes can be used to identify toxic solutions within one hour?

 

3. 27 small balls. One of them is a little heavier than other balls. Give you a balance. It can be called three times at most to find this special ball.

 

4. there are 12 balls of the same color and size, only one of which is known to have slightly different weights (Tip: But I don't know whether it is heavy or light). Now I use a balance without weight, you can search for this special ball three times at most.

 

5. Mo has a 40-pound weight. Once he fell to the ground, he fell into 4 parts, heartache. However, he accidentally discovered that the four weight fragments could be called 1 ~ On Apsara stack ~ The weight of any integer in the range of 40. What is the weight of each of the four parts?

 

6. Divide the range [0, 1] into three segments on average, and dig out the middle segment (1/3, 2/3), and then dig the remaining two segments into the middle 1/3 respectively. In this way, if there are any points in the range [0, 1] that will never be dug out? If so, what are the laws of the coordinates of these points?

 

 

 

The answer is below. Please think about it first and then read the answer!

 

 

 

 

 

 

 

 

 

 

Answer: 

If you find an error or have a better solution, leave a message to tell me. Thank you. The second and second questions involve binary ideas, which are familiar to everyone. It is a warm-up. In the next four questions, we need to use the three-in-one and so-called "balanced three-in-one" ideas to solve them, which is quite interesting.

 

 

Problem1: 

  Answer: Press 512, 16 ,...,

  Analysis:

The first problem can be easily solved using binary encoding. I believe that computer learning will not be difficult.

According to the characteristics of binary encoding, the weights of each digit in the n-bit binary number are 2 ^ 0, 2 ^ 1, 2 ^ 2 ,...... 2 ^ (n-1 ). N-bit Unsigned binary numbers can represent 0 to (2 ^ N)-1, N in total.

However, the binary digits are in two states: 1 and 0, which correspond to the "give" and "not give" statuses of the Apple bag in the question. Therefore, you only need to load each bag into 2 ^ 0, 2 ^ 1, 2 ^ 2 ,...... , 2 ^ 9 Apple can meet the question requirements. For example, if you need 66 apples, because the binary value of 66 is 1000010, James only needs to set the number of apples to 2 ^ 1 (2) and 2 ^ 6 (64) the bag is red.

 

 

Problem2: 

  Answer and analysis:

If there is no one-hour time limit, the problem can be solved using the binary search idea. (For the first time, put 8 of the 16 solutions into a test tube, and then add reagent A to check whether there is any reaction, and then subdivided according to the results. In this way, only four test tubes are needed, but it takes four hours.) This method does not work after the one-hour limit is reached. A correct answer is as follows:

 

First, the numbers of 16 solutions are numbered 0 to 15. The binary format of the numbers is as follows:

 

0001

0010

0011

0100

0101

0110

0111

1000

1001

1010

1011

1100

1101

1110

1111

 

Then, take four test tubes. The first test tube is added with a serial number. In binary form, the first (indicated by the serial number) is 1, and the second test tube is added with a serial number and the second is 1, the other two test tubes are respectively added with a solution numbered 3, 4 bits as 1. Then add the reagent ainto four test tubes. Then you can know the numbers of toxic solutions by checking the reaction of the test tubes. For example, if a reaction occurs in the tubes 1st, 2, and 4, we know that the solution 7th is toxic. The reason is that the binary code of 7 is 1011, so solution 7 is the only solution that has been added to test tubes 1, 2, and 4 but not test tubes 3.

 

Problem3: 

  Answer and analysis:

The 3rd problems can be solved using the triplicate principle. Let's talk about the three-digit system. Similar to the binary system, the weights of each digit in the three-digit system are respectively 3 ^ 0, 3 ^ 1, 3 ^ 2 ,......., 3 ^ n. The three numbers 0, 1, and 2 represent numbers. Therefore, each three-digit number has three states.

There are three results for weighing each time: heavier on the left, heavier on the right, and balanced. We can set the numbers on the left to 1, the numbers on the right to 2, and the numbers on the balance to 0.

 

First, the 27 balls are numbered from 0 to 26. The three-in-number format is as follows:

 

000

001

002

010

011

012

020

021

022

100

101

102

110

111

112

120

121

122

200

201

202

210

211

212

220

221

222

 

For the first weighing, place the ball (9) with the serial number in the Three-in-three system, and the ball (9) with the serial number of 1st bits and 2 on the right, if the number is 0.

 

For the second weighing, place the ball (9) numbered in the Three-in-three system with 2nd bits as 1 on the left, and the ball (9) numbered in 2nd bits as 2 on the right, if the number is 0.

 

For the third weighing operation, place the ball (9) numbered in the Three-in-three system with 3rd bits as 1 on the left, and the ball (9) numbered in 3rd bits as 2 on the right, if the number is 0.

 

Well, based on the three weighing results, we can know the number of the heavier ball. Assume that the numbers of the three weighing results are 0, 1, and 2 respectively, then we can know that the heavier one is the 21 ball. Because the tridecimal System of 21 is (210), only the ball 21 is not placed during the first weighing, the second is placed on the left, and the third is placed on the right.

 

Problem4: 

Answer and analysis:

Question 4 is an upgraded version of question 3.

If you know that the same ball is lighter or heavier than other balls, it is easy to do, as long as the 12 balls are divided into 4, 4, 4 three heaps, said 3 times can find the same ball, the method is very simple.

 

However, I don't know whether the ball is light or heavy, and the above method will not work. A feasible solution is as follows:

 

Assuming that the same ball is heavier than the normal ball, and N balls are extracted from 12, the combination of the abnormal ball is always heavier than that of the abnormal ball.

12 small balls are numbered 3-digit (000) to (102), as follows:

000

001

002

010

011

012

020

021

022

100

101

102

 

 

For the convenience of the following discussion, assuming that the number of the exception ball is xyz, then our goal is to define the value of X, Y, and Z three times. The idea of finding a strange ball is to narrow down the scope through weighing, and finally deduce the number of an abnormal ball.

 

Note that the delimiter in the number is 0, and each of the numbers 1 and 2 has four. Therefore, place the positions 1 and 2 on both sides of the balance once. The results of the first call are divided into the following two situations:

 

(1) If the balance is not balanced during the first weighing, then the strange ball must be in the ball where the serial number is 1 or 2, that is, z is equal to 1 or 2.

 

The following eight numbers are numbered with 1 or 2:

001

002

011

012

021

022

101

102

 

So we reduced the search scope to the eight balls above.

 

Note that in the eight numbers, the second digit is 1 and 2 respectively. Here are the four:

 

011

012

021

022

 

Therefore, for the second weighing, place the second digit of the five numbers listed above as 1 and 2 respectively on both sides of the balance.

The results of the second weighing can be divided into the following two situations:

 

<1> the balance is not balanced during the second weighing, so we can be sure that the strange ball must be in the second ball numbered 1 or 2, and Y is equal to 1 or 2.

Assume that the ball is 011 + 012> 021 + 022

Assuming that the first weighing result is that the ball with the lowest digit is heavier than the second digit, we can be sure that the ball with the 011 or the 022 is lighter.

For the third weighing, you only need to weigh any one of the 011 or 022 balls and any other ball. If the balance is normal, the ball is abnormal.

 

<2> If the balance is balanced during the second weighing, we can be sure that the second digit of the abnormal ball number must be 0. Then, you can find the number of the abnormal ball by the highest bit of the number.

 

(2) If the balance is balanced during the first weighing, The seek position of the same ball number must be 0. Similarly, you can refer to the above idea to find the strange ball through the second and second digits of the number, so it won't be too long here.

 

Another solution to this problem is http://blog.sina.com.cn/s/blog_49d0731a010007i0.html.

 

 

Problem5: 

 Answer:1, 3, 9, 27

  Analysis:

The 5th issue is the weight problem of bachet de meziriac ).

This involves the so-called "balanced triplicate system. The balanced tridecimal system, also known as symmetric tridecimal system, is a three-digit base with the weights of 3 ^ 0, 3 ^ 1, 3 ^ 2 ......., 3 ^ N, with-, 1 as the basic digital three-digit counting system. The value range of the N-bit three-digit number is-(3 ^ N)-1)/2 ~ (3 ^ N)-1)/2.

You need to understand that a weight can be placed on the same side of the item to be weighed, or on the opposite side, or not. Three States of the weight can be expressed as: Do not put (0), put on the peer side of the item (+ 1), put on the same side of the item (-1 ).

Therefore, the weight of each weight fragment is the weight of each balanced tridecimal digit (3 ^ 0, 3 ^ 1, 3 ^ 2, 3 ^ 3), that is, 1, 3, 9, 27.

 

To sum up, the preceding questions 1 and 2 are solved by the binary principle, while questions 3, 4 and 5 are solved by the triplicate principle. In general, the principle is the same. The core difference is that binary digits have two States, and triplicate digits have three states. (Nonsense !)

 

Problem6: 

 Answer: kangtuo's Three-Point Collection

  Analysis:

First, the decimal number between [0, 1] is represented by a three-digit number, and it is painted on the number axis. You will find that, for the first time, all the numbers with 1st decimal places being 1 are dug out, and for the second time, all the numbers with 2nd decimal places being 1 are dug out.

In essence, it is to dig out all numbers containing digit 1 in the Tri-hexadecimal representation. Therefore, the remaining number is a set of all numbers that do not contain 1 in the three-digit notation on the [0, 1] interval. This set is the so-called contos three-point set.

 

Interestingly, the number of elements in the contos triples is essentially the same as the number of real numbers in the interval [] (the strict expression should be "equipotential ")!

If the elements of set a and Set B can establish a "one-to-one correspondence" relationship, we will say that A and B are "equipotential ". For example, the even number set E and the natural number set N are equipotent, because for any number A in the even number set, a number A/2 can correspond to it in the natural number set, and vice versa.

 

The following is a simple example of an equipotential between the kangtuo Three-Point Set and the [0, 1] interval.

First, the decimal point in the range [0, 1] is expressed in binary notation.

Change "1" in the number to "2", so that the number is exactly the same as that in the contos three-point set. In turn, change all "2" in any number (binary representation) in the contos trigger set to "1", which is a unique binary decimal corresponding to the [0, 1] interval. Therefore, contos three-point set and [0, 1] can establish a one-to-one ing relationship, which is equivalent.

Overall = part. Amazing, right? There will be a lot of interesting things in the endless field. For example, you can prove that a small segment of a line is in an equipotential with a point in a straight line, and that a complete set of values is in an equipotential with a natural set, and so on.

Interesting questions about the binary and triplicate formats

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.