#include<iostream>
using namespace std;
class Solution
{
public:
bool isPerfectSquare(int num)
{
int left = 0;
int right = num / 2;
while (left <= right)
{
int mid = left + (right - left) / 2;
int square = mid * mid;
if (square == num) { return true; }
else if (square > num) { right = mid - 1; }
else { left = mid + 1; }
}
return false;
}
};
int main()
{
Solution solution;
int a1 = 16;
int a2 = 9;
int a3 = 14;
cout << solution.isPerfectSquare(a1) << endl;
cout << solution.isPerfectSquare(a3) << endl;
system("pause");
return 0;
}