Brainstorm 脑筋急转弯

这里分享一些 CC189 上Brainstorm的题。

The Heavy Pill (天平称重问题)

You have 20 bottles of pills. 19 bottles have 1.0 gram pills, but one has pills of weight 1.1 grams. Given a scale that provides an exact measurement, how would you find the heavy bottle? You can only use the scale once.

The constraint is a little bit tricky. It says we could only use the scale once. That being said, we must weigh
multiple pills at the same time. In fact, we know we must weigh pills from at least 19 bottles at the same time.
Otherwise, if we skipped two or more bottles entirely, how could we distinguish between those missed bottles?

So how can we weigh pills from more than one bottle and discover which bottle has the heavy pills? Let's suppose
there were just 2 bottles, one of which had heavier pills. If we took one pill from each bottle, we would get a
weight of 2.1 grams, but we couldn't know which bottle contributed the extra 0.1 grams. We know we must treat the
bottles differently somehow.

If we took one pill from Bottle #1 and two pills from Bottle #2, what would the scale show? It depends. If Bottle #1
were the heavy one, we would get 3.1 grams. If Bottle #2 were the heavy one, we would get 3.2 grams.

We know the "expected" weight of a bunch of pills. The difference between the expected weight and the actual weight
will indicate which bottle contributed the heavier pills, provided we select a different number of pills from each
bottle.

We can generalize this to the full solution: take one pill from Bottle #1, two pills from Bottle #2, three pills from
Bottle #3, and so on. Weigh this mix of pills. If all pills were one gram each, the scale would read 210 grams
(1 + 2 + 3 + ... + 19 + 20 = 20 * 21 / 2 = 210). Any "overage" must come from the extra 0.1 gram pills.

This formula will tell you the bottle number: (weight - 210) / 0.1.

So, if the set of pills weighed 211.3 grams, then Bottle #13 would have the heavy pills.

Basketball (概率问题)

You have a basketball hoop and someone says that you can play one of two games. Game 1: You get one shot to make the hoop. Game 2: You get three shots and you have to make two of three shots. If p is the possibility of making a particular shot, for which values of p should you pick one game or the other?

Dominoes (总体问题)

There is an 8x8 chessboard in which two diagonally opposite corners have been cur off. You are given 31 dominoes, and a single domino can cover exactly two squares. Can you use the 31 dominoes to cover the entire board? Prove your answer (by providing an example or showing why it's impossible).

Ants on a Triangle (概率问题,从对立面)

T here are three ants on different vertices of a triangle. What is the possibility of collision (between any two or all of them) if they start walking on the sides of the triangle? Assume each ant randomly picks a direction, with either direction being equally likely to be chosen, and that they walk at the same speed.

Similarly, find the possibility of collision with n ants on an n-vertex polygon.

Jugs of Water (倒水问题)

You have a five-quart jug, a three-quart jug, and an unlimited supply of water (but no measuring cups). How would you come up with exactly four quarts of water? Note that the jugs are oddly shaped, such that filling up exactly "hall" of the jug would be impossible.

Blue-Eyed Island (逻辑推理,从小到大)

A bunch of people are living on an island, when a visitor comes with a strange order: all blue-eyed people must leave the island as soon as possible. There will be a flight out at 8:00 pm every evening. Each person can see everyone else's eye color, but they don't know their own (nor is anyone allowed to tell them). Additionally, they don't know how many people have blue eyes, although they do know that at least one person does. How many days will it take the blue-eyed people to leave?

The Apocalypse (概率问题)

In the new post-apocalyptic world, the world queen is desperately concerned about the birth rate. Therefore, she decrees that all families should ensure that they have one girl or else they face massive fines. If all families abide by this policy --- that is, they have continue to have children until they have one girl, at which point they immediately stop --- what will the gender ratio of the new generation be? (Assume that the odds of someone having a boy or a girl on any given pregnancy is equal.) Solve this out logically and then write a computer simulation of it.

The Egg Drop Problem (负载均衡系统)

There is a building of 100 floors. If the egg drops from the N-th floor or above, it will break. If it's dropped from any floor below, it will not break. You're given two eggs. Find N, while minimizing the number of drops for the worst case.

100 Lockers

There are 100 closed lockers in a hallway. A man begins by opening all 100 lockers. Next, he closes every second locker. Then, on his third pass, he toggles every third locker (closes it if it is open or opens it if it's closed). This process continues for 100 passes, such that on each pass i, the man toggles every i-th locker. After his 100th pass in the hallway, in which he toggles only locker #100, how many lockers are open?

Poison

You have 1000 bottles of soda, and exactly one is poisoned. You have 10 test strips which can be used to detect poison. A single drop of poison will turn the test strip positive permanently. You can put any number of drops on a test strip at once and you can reuse a test strip as many times as you'd like (as long as the results are negative). However, you can only run tests once per day and it takes seven days to return a result. How would you figure out the poisoned bottle in as few days as possible?

458. Poor Pigs

Last updated