fork download
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4. #include <iomanip>
  5. using namespace std;
  6.  
  7. int main(){
  8. double left,right,x,ans,eps;
  9. eps=1e-10;
  10. cin>>x;
  11. left=0;
  12. right=x;
  13. while(right-left>=eps){
  14. ans=((left+right)/2)*((left+right)/2);
  15. if(ans>x){
  16. right=(left+right)/2;
  17. }else{
  18. left=(left+right)/2;
  19. }
  20. }
  21. cout << left << " " << right<<endl;
  22. cout<<setprecision(2)<<fixed<<left;
  23. //(left+right)/2;
  24.  
  25. return 0;
  26. }
Success #stdin #stdout 0s 5300KB
stdin
6
stdout
2.44949 2.44949
2.45