标签:
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.
public class Solution { public int bulbSwitch(int n) { //numbers with odd number of divisor will be left on. //such as 1, 4, 9, 16, .... return (int) Math.sqrt(n); } }
标签:
原文地址:http://www.cnblogs.com/neweracoding/p/5629747.html