fork download
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <math.h>
  4. using namespace std;
  5. double bin_s(double a){
  6. double l=0, r=1000 , eps=1e-7;
  7. while(abs(l-r)>eps){
  8. double m=(l+r)/2;
  9. double x=pow(m,2)+sqrt(m);
  10. if(a>x)l=m;
  11. else r=m;
  12. }
  13. return l;
  14. }
  15. int main() {
  16. double a;
  17. cin>>a;
  18. cout<<fixed<<setprecision(8)<<bin_s(a);
  19.  
  20. return 0;
  21. }
  22.  
Success #stdin #stdout 0s 5284KB
stdin
2.0000000000
stdout
0.99999999