319. Bulb Switcher There are n bulbs that are initially off. You first turn on all the bulbs, then you turn off every second bulb. On the third round, you toggle every third bulb (turning on if it’s
There are n bulbs that are initially off. You first turn on all >the bulbs. Then, you turn off every second bulb. On the >third round, you toggle every third bulb (turning on if it’s >off or turning
翻译 这儿有n个灯泡被初始化。首先,你点亮所有的灯泡。然后,你关掉每第二个灯泡。在第三回,你切换每第三个灯泡(如果它是关闭的则开启它,如果它是开启的则关闭它)。对于第i回,你切换每第i个灯泡。对于第n回,你仅仅切换最后一个灯泡。找出在n回之后还有多少个灯泡是亮着的。 原文 There are n bulbs that are initially off. You first turn on
Description There are n bulbs that are initially off. You first turn on all the bulbs, then you turn off every second bulb. On the third round, you toggle every third bulb (turning on if it’s off or
Description There are n bulbs that are initially off. You first turn on all the bulbs, then you turn off every second bulb. On the third round, you toggle every third bulb (turning on if it’s off or