fork(1) download
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7. double c, eps;
  8. cin >> c >> eps;
  9.  
  10. double a = 1.0;
  11. double b = c;
  12. double m;
  13.  
  14. while ((b - a) > eps) {
  15. m = (a + b) / 2.0;
  16.  
  17. if (m * m > c)
  18. b = m;
  19. else
  20. a = m;
  21. }
  22.  
  23. double pkw = (a + b) / 2.0;
  24.  
  25. cout << pkw << endl;
  26.  
  27. return 0;
  28. }
  29.  
Success #stdin #stdout 0.01s 5312KB
stdin
Standard input is empty
stdout
0.5