2 solutions

  • 2
    @ 2025-7-18 17:04:26

    #include <bits/stdc++.h> using namespace std;

    int main() { double x, n, s = 1.0; cin >> x >> n; for (int i = 1; i <= n; i++) { s = (s + x / s) / 2; } cout << fixed << setprecision(3) << s; return 0; }

    • -1
      @ 2025-7-18 17:03:12

      #include <bits/stdc++.h>

      using namespace std; int a[25005], b[25005];

      int main() { double x, n, a = 1.0; cin >> x >> n; for (int i = 1; i <= n; i++) { a = (a + x / a) / 2; }

      cout << fixed << setprecision(3) << a;
      return 0;
      

      }

      • 1

      Information

      ID
      205
      Time
      1000ms
      Memory
      64MiB
      Difficulty
      2
      Tags
      # Submissions
      55
      Accepted
      35
      Uploaded By