fork download
  1. #include <bits/stdc++.h>
  2.  
  3. #define nl '\n'
  4. #define ll long long int
  5.  
  6. using namespace std;
  7.  
  8. //* Use this for USACO Problems
  9. void setIO(string s)
  10. {
  11. freopen((s + ".in").c_str(), "r", stdin);
  12. freopen((s + ".out").c_str(), "w", stdout);
  13. }
  14.  
  15. double n;
  16. bool test(double k)
  17. {
  18. return k * k + sqrt(k) >= n;
  19. }
  20.  
  21. int main()
  22. {
  23. // setIO("circlecross");
  24. ios_base::sync_with_stdio(0);
  25. cin.tie(0);
  26. cout.tie(0);
  27. int t = 1;
  28. // cin >> t;
  29.  
  30. while (t--)
  31. {
  32. cin >> n;
  33. double l, r, m;
  34. l = 0;
  35. r = 1e10;
  36. for (int i = 0; i < 100; ++i)
  37. {
  38. m = (l + r) / 2;
  39. if (test(m))
  40. {
  41. r = m;
  42. }
  43. else
  44. {
  45. l = m;
  46. }
  47. }
  48. cout << setprecision(20) << l << nl;
  49. }
  50. }
  51.  
Success #stdin #stdout 0.01s 5272KB
stdin
Standard input is empty
stdout
0