3 solutions

  • 1
    @ 2026-1-9 22:38:20

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

    int main() { int a, b; double c = 1.0; cin >> a >> b; for (int i = 1; i <= b; i++) { c = (c + a * 1.0 / c) / 2; } printf("%.3lf", c); return 0; }

    • 1
      @ 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; }

      • -2
        @ 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
        61
        Accepted
        40
        Uploaded By