|
回复:囚 犯 问 题 新 版 (自 编 )[:D)]
Let n = number of current on switches, and a = n mod 15.If a is odd,turn on (15-a)/2 switches and turn off (15+a)/2 switches. If a = 0, turn off 15 switches. If a is even and > 0, turn on 7 and turn off 8 so it becomes odd.
Are there really bad prisoners that should not be released? If so, we change the rule to 14 switches every prizoner, but turn on an odd number of lights at the beginning. :)www.ddhw.com
|
|
|