找规律
const int MAXN = 2e5;
class Solution {
public:
long long square[MAXN];
int pos=0;
int bulbSwitch(int n) {
for(long long i=1;i<MAXN;i++)
{
if(i*i > INT_MAX)
break;
square[++pos] = i*i;
}
int l = 1;
int r = pos;
while(l<=r)
{
int mid = (l+r)/2;
if(n>square[mid])
{
l = mid+1;
}
else if(n<square[mid])
{
r = mid-1;
}
else
{
r=mid;
break;
}
}
return r;
}
};