二分法解方程,因为单调,精度到了0.1的三次方终止

package org.niuke.solution97;

import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        double d = scanner.nextDouble();
        //0.1*0.1*0.1=0.0001
        double l = 0.0, r = d;
        while (r - l > 0.0001) {
            double mid = (r + l) / 2;
            if(Math.pow(mid, 3) < d){
                l = mid;
            }else{
                r = mid;
            }
        }
        if(Math.pow(Math.round(r),3) == d){ //216的开方 6.0,精益求精,5.9
            System.out.printf("%.1f", (double) Math.round(r));
        }else{
            System.out.printf("%.1f", r);
        }
    }

}