package test;
import java.util.Scanner;
public class sqrt {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
double m = in.nextDouble();
System.out.println(dichotomy(m));
System.out.println(NewtonMethod(m));
//如果保留小数位置就System.out.printf("%.2f",dichotomy(m));这种
//System.out.println((int) Math.floor(num));向下取整
/System.out.println((int) Math.rint(num));四舍五入取整
//System.out.println((int) Math.floor(num));向上取整
}
public static double dichotomy(double m)
{
double left = 0.0;
double right = m;
double p=1e-5;
double mid=0;
while(Math.abs(mid*mid-m)>p)
{
mid=(left+right)/2;
if(mid*mid<m)
{
left=mid;
}
else if(mid*mid>m)
{
right=mid;
}
else return mid;
}
return mid;
}
public static double NewtonMethod(double m)
{
double x=1.0;
double p=1e-5;
while(Math.abs(x*x-m)>p)
{
x=(x+m/x)/2;
}
return x;
}
}