#include <iostream>
#include <cmath>
#include <iomanip>
#include <vector>
using namespace std;
//求數列an的第n項
double ArithmeticalMean(double a, double b, int n)
{
vector<double> temp1(n + 1);
vector<double> temp2(n + 1);
temp1[0] = a;
temp2[0] = b;
for (int i = 1; i <= n; ++i)
{
temp1[i] = (temp1[i - 1] + temp2[i - 1]) / 2;
temp2[i] = sqrt(temp1[i - 1] * temp2[i - 1]);
}
return temp1[n];
}
int main()
{
cout << setprecision(16) << ArithmeticalMean(200000, 1, 5) << endl;
cout << ArithmeticalMean(200000, 1, 100) << endl;
}