- C20250278's blog
7777
- 2023-3-6 9:36:14 @
#include<bits/stdc++.h>
using namespace std;
double mysqrt(double x){
double L=0,R=x;
while (R-L>0.000001){
double M=(L+R)/2;
if (M*M>x) R=M;
else L=M;
}
return L;
}
int main(){
//solve sqrt(x) 精度0.0001
double x = 39;
cout<<fixed<<setprecision(8)<<mysqrt(x)<<endl;
return 0;
}