Leetcode 319 Bulb Switcher 找规律

有n盏关着的灯,第k轮把序号为k倍数的关着的灯打开,开着的灯关闭。

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

 

posted @ 2016-01-16 20:59  Breeze0806  阅读(202)  评论(2编辑  收藏  举报