The minimum number of 25 horses can be selected. The first three or 25 horses can be selected.

Source: Internet
Author: User

The minimum number of 25 horses can be selected. The first three or 25 horses can be selected.

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

Http://www.llwjy.com/blogdetail/208a6ac5e85d6078810047731d02c062.html

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

Problem description

There are 25 horses and 5 runways. Only 5 horses can be created at a time. How many times can the first 3 horses be selected?


Solution

The following solutions are as follows:

1) divide 25 horses into five groups to race each other and record the rankings of each group;

2) Take the first place in each group from the five groups and run the sixth game. Assume that the ranking of the sixth game is as follows: the first place is in group X, the second is in group Y, the third is in group Z, the fourth is in group J, and the fifth is in group K;

3) take the second and third places in group X, the first and second places in group Y, and the first place in group Z to run 7th games;

The last three results are: the first place is the first place in the sixth field, the second is the first place in the seventh field, and the third is the second place in the seventh field.


Solution Analysis

In the first step of the solution, we will no longer be arrogant. We will start from step 2. In the sixth field, we will take the first place in each group for a race, the first place in the sixth game must be the fastest among all the horses, so the first place is determined. At the same time, after the sixth game is completed, the highest rank of all horses is determined. We will briefly describe the following:

Group: Group 1 group 2 group 3 group 4 group 5

Group X: first place -- best second -- best third -- best fourth -- best fifth

Group Y: Best second -- best third -- best fourth -- best fifth -- best sixth

Z group: Best third -- best fourth -- best fifth -- best sixth -- best seventh

Group J: Best 4-best 5-best 6-best 7-best 8

Group K: Best fifth -- best sixth -- best seventh -- best eighth -- best ninth

Therefore, for the seventh time, we only need to put horses that may be the first three (the second and third in group X, the first and second in group Y, and the first in group Z) (exactly five horses) to race the seventh game, we can know which three horses are the first three.


Interview Expansion

The above question can be used as an interview question to test the way the interviewee thinks. If it is related to a computer, we can also modify this question to make it a description of the computer's needs, below is my adaptation:


Problem description: there is currently an interface that provides sorting (descending) between user activity levels. However, this interface has a disadvantage that five users can be processed at a single operation, now there are 25 users. How many times can this interface be called at least to get the first three users who are active?


Of course, there should be many adaptations of this question. The purpose of introducing this question is to name a question. After completing the step (the sixth case ), when we start the next step, we hope we can stop and think about whether this step has an impact on the whole. Maybe this is the stop, which can reduce our detours.


Another interview question

There is also an interview question, which is also a test of the way of thinking. I would like to share with you that there are 1000 bottles of liquid (normal, non-toxic), but due to staff mistakes, the poison is dropped into one of the bottles, and the appearance and smell cannot tell which one is contaminated. We only know that the poison is sent for 7 days, there are 10 white mice in the lab. How can I know which bottle is contaminated after 7 days?

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.