Algorithm-track and horse-Baidu face questions

Source: Internet
Author: User

March 4, 2015

25 horse races, 5 runways, which means that 5 horses can compete at the same time. Ask the least number of races to know the 5 horses that run fastest.


Divide the horse into a, B, C, D, E five groups.
第1-5次 Competition: Each group to play the game, to decide the rank of each group
A1, A2, A3, A4, A5,
B1, B2, B3, B4, B5,
。。。。
。。。。。。 E4, E5.
6th races: A1, B1, C1, D1, E1,
First place is the fastest runner.


7th competition: Match the next dismount of the last group and the remaining 4 horses of the number 1th,
The first is the second fastest horse, because there are only 4 places, so the slowest horse to run and the remaining horses in the group are all eliminated.
8th tournament: Match the next horse of the last group, the next horse of the last group and the remaining 3 horses.
The first is the third fastest horse, because there are only 3 places, so the slowest running two horses and the remaining horses in the group are all eliminated.
In the remaining races to eliminate the slow, will be ranked later in the game, up to the 10th time to choose the fastest 5 horses. If the first few in a match are in the same group and the selected Ma Jiajue is greater than or equal to 5, the top 5 can be identified in advance.
So you can pick the fastest 5 horses in 8-10 times.

Algorithm-track and horse-Baidu face questions

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.