哪个开关?
Which Switch?
题目详情
一个房间里有一只灯泡,房间外有三个开关。三个开关现在都是关闭状态,且只有一个开关能控制灯泡。
你可以在进房间前随意开关任意开关任意次。问:为了确定哪个开关控制灯泡,最少需要进房间几次?
提示:灯泡点亮会发热,而且升温不是瞬间完成的。
There is a light bulb inside a room and three switches outside. All switches are currently in off state and only one switch controls the light bulb. You may turn any number of switches on or off any number of times you want. How many times do you need to go into the room to figure out which switch controls the light bulb?
Hint
A lighted bulb also emits heat and gets hot slowly (not instantaneously!)
解析
只需要进房间 1 次。
做法:
- 打开开关 1,等待一段时间(例如 10 分钟),然后关掉开关 1。
- 打开开关 2,立刻进房间查看灯泡。
判断:
- 灯泡亮:开关 2 控制。
- 灯泡灭但摸起来温热:开关 1 控制。
- 灯泡灭且冰凉:开关 3 控制。
Original Explanation
1
Solution
The bulb gets hot slowly when turned on. Turn on the switch # for 10 minutes, turn it off and turn on the switch # and get into the room. There are possible cases.
- If the bulb is on, then switch # controls the bulb.
- If the bulb is off, but hot, then switch # controls the bulb.
- If the bulb is off and cool, then switch # controls the bulb.
Thus, we can infer the switch that controls the bulb in one entry.
Follow up question
What if there were switches?
Follow up answer
Assuming that modern bulbs heat up slowly, we can infer this in one entry. Turn on the switch # and # keeping others off. Wait for 10 minutes. Turn off #, turn on #, and quickly enter the room. Following are the possible states and the corresponding switch that controls the bulb.
| State | Inferred Switch | |
|---|---|---|
| on and hot | 1 | |
| off but hot | 2 | |
| on but cool | 3 | |
| off and cool | 4 |
The following table shows this information in a grid format:
| On | Off | |
|---|---|---|
| Hot | 1 | 2 |
| Cold | 3 | 4 |