当前位置:网站首页>acwing 790. The third root of a number (dichotomy)

acwing 790. The third root of a number (dichotomy)

2022-06-13 09:25:00 Age worry

subject :790. The third root of a number
 Insert picture description here

#include<iostream>
#include<cstdio>
#include<algorithm>

using namespace std;

int main(){
    
    double n;
    scanf("%lf",&n);
    double i=-10000,j=10000;
    while(i+1e-8<j){
    
        double mid=(i+j)/2;
        if(mid*mid*mid<n) i=mid;
        else j=mid;
    }
    printf("%.6lf",i);
    return 0;
}

原网站

版权声明
本文为[Age worry]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202270532192191.html