```
class Solution {
public:
bool isPerfectSquare(int num) {
if(num%10==2 || num%10==3 || num%10==7 || num%10==8) return false;
int low=1;
int high = num;
while(low<high){
long mid = low + (high-low)/2;
if(mid*mid<num) low = mid+1;
else if(mid*mid>num) high=mid;
else return true;
}
return low*low==num;
}
};
```