java.io Bag and cup surveying building

Source: Internet
Author: User
1 java.io

Character Stream: Reader

BYTE stream: InputStream

2 cup Test building

A cup, if the nth layer is broken, then in any higher than N of the floor will break, if not broken in the first layer, then in any lower than m floor will not break, give you two such cups, let you in the 100-storey high floor test, ask for a minimum number of tests to find the cup that happens to break the glass floor.

Analysis:

1 if there is only one cup, you need to go up from the 1th layer and test it by layer.

2 Now with one more cup, you can use this cup to determine the approximate range of the critical floor, and then the first Cup will continue in the way of analysis 1. The number of tests required is approximately 100^ (1/2) =10

Answer:

1 will be 100 layers of k consecutive floors, the number of floors per floor is F layer, so that the problem becomes the first cup to determine the floor area, with a second Cup to determine the critical floor problem.

2 starting from the first floor interval, the number of test times for the K-i floor interval is more than thei-1 of section K.

The maximum number of floors in a critical floor can be measured at 3 K times: s=k+ (K-1) +......+1= (k^2-k)/2

4 for the subject s>100, the solution to k=14

Extended:

1 if there are 3 cups, K can measure the maximum number of floors of the critical floor: S=s2(K) +s2(K-1) +......+3= (k^3-k)/6

Related Article

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.