📜  算法|杂项|问题11

📅  最后修改于: 2021-06-29 14:23:01             🧑  作者: Mango

给定8个相同的硬币,其中一个硬币很重,并且具有平底锅平衡。要找到较重的硬币,需要多少次最小测量?
(A) 2
(B) 3
(C) 4
(D) 7答案: (A)
解释:

Divide the coins into three groups and name the coins according to there group:
A: A1, A2, A3
B: B1, B2, B3
C: C1, C2

Measure group A and group B. Two cases arise:
1. They are equal. One more measurement is needed to find the heavy 
   coin in group C. Total two measurements needed in this case.
2. They are not equal. Find the heavy group, say A. Pick any two coins
   from this group,  say A1 and A3. Measure A1 and A3 in the pan balance. 
   Two cases arise:
   2.1 They are equal. A2 is the heavy coin. Total two measurements 
       needed.
   2.2 They are not equal. It is known which of A1 or A3 is heavy. 
       Total two measurements needed.
So, the above observations says that in any case, 2 measurements are enough
to find the heavy coin.

Follow up:
Generalize the minimum number of measurements for n coins 
with one coin heavy.

这个问题的测验