###### 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 off or turning off if it's on). For the ith round, you toggle every i bulb. For the nth round, you only toggle the last bulb. Find how many bulbs are on after n rounds.

Example:

Given n = 3.
At first, the three bulbs are [off, off, off].
After first round, the three bulbs are [on, on, on].
After second round, the three bulbs are [on, off, on].
After third round, the three bulbs are [on, off, off].
So you should return 1, because there is only one bulb is on.

class Solution {
public:
int bulbSwitch(int n) {
return sqrt(n);
}
};

#### leetcode 319. Bulb Switcher-灯泡开关

2016-05-22 17:03:27

#### [LeetCode]-319. Bulb Switcher (Medium)(Java)

2016-03-01 11:18:32

#### LeetCode319——Bulb Switcher

2015-12-21 09:58:13

#### LeetCode 319 -Bulb Switcher ( JAVA )

2016-04-10 11:24:18

#### leetcode 672. Bulb Switcher II

2017-09-05 22:34:03

#### leetcode 319. Bulb Switcher 轮流开关灯泡 + 数学公式

2017-10-02 11:30:57

#### 【Leetcode】Bulb Switcher

2015-12-21 23:32:55

#### 319. Bulb Switcher && 672. Bulb Switcher II

2017-09-03 13:23:31

#### Bulb Switcher II问题及解法

2017-09-13 09:10:38

#### [leetcode] 319. Bulb Switcher

2015-12-19 19:47:18

## 不良信息举报

319. Bulb Switcher