#include <bits/stdc++.h>
using namespace std;
float squareRoot(int number, int precision)
{
int low = 0, high = number;
float ans;
while (low <= high) {
int mid = low+ (high-low)/2;
if (mid * mid == number) {
ans = mid;
break;
}
if (mid * mid < number) {
low = mid + 1;
ans = mid;
}
else {
high = mid - 1;
}
}
// For computing the fractional part
// of square root upto given precision
float increment = 0.1;
for (int i = 0; i < precision; i++) {
while (ans * ans <= number) {
ans += increment;
}
ans = ans - increment;
increment = increment / 10;
}
return ans;
}
int main()
{
cout << squareRoot(50, 3) << endl;
return 0;
}