import java.util.Scanner;
/**
* HJ107 求解立方根 - 中等
*/
public class HJ107 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (sc.hasNextDouble()) {
double num = sc.nextDouble();
// double x = method1(num);
double x = Dichotomy(num);
System.out.printf("%.1f", x);
}
sc.close();
}
/**
* 1. 牛顿迭代法
*
* @param num
* @return
*/
private static double method1(double num) {
double x = 1.0;
double x1 = x + (num - x * x * x) / (3 * x * x);
while (x - x1 > 0.000001 || x - x1 < -0.000001) {
x = x1;
x1 = x + (num - x * x * x) / (3 * x * x);
}
return x1;
}
/**
* 二分查找法
*
* @param num
* @return
*/
private static double Dichotomy(double num) {
double right, left, mid = 0.0;
//一定要注意边界条件,输入的num可能是负数 将x<-1的边界范围定为[x,1],x>1的边界范围定为[-1,x]
right = Math.max(1.0, num);
left = Math.min(-1.0, num);
while (right - left > 0.001) {
mid = (left + right) / 2;
if (mid * mid * mid > num) {
//如果乘积大于num,说明立方根在mid的左侧
right = mid;
} else if (mid * mid * mid < num) {
//如果乘积小于num,说明立方根在mid的右侧
left = mid;
} else {
return mid;
}
}
return right;
}
}