public int bulbSwitch(int n) {
        if(n<=0) return 0;
        int cnt=0;
        for(int i=1;i<=n;++i) {
            int a = (int) Math.sqrt(i);
            if (a * a == i) cnt++;
        }
        return cnt;
    }