题目:
题解:
cpp
bool isPerfectSquare(int num)
{
long long left=0;
long long right=num;
while(left<=right)
{
long long mid=(left+right)/2;
long long ans=mid*mid;
if(ans<num)
{
left=mid+1;
}
else if(ans>num)
{
right=mid-1;
}
else
{
return true;
}
}
return false;
}