Key of this problem is to find from 2 to n there are how many numbers that can be divided as n=a*a.

```
int bulbSwitch(int n)
{
if (0 == n)
return 0;
int x = 2;
int res = 1;
for (; pow(x, 2) < INT_MAX && pow(x, 2) <= n; ++x)
++res;
return res;
}
```