#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <iterator>
#include <functional>
#include <complex>
#include <queue>
#include <stack>
#include <cmath>
#include <cassert>
#include <cstring>
using namespace std;
typedef long long LL;
typedef complex<double> CMP;

class FlightScheduler { public:
	double f(double n, int distance, int K, int emptyMass, int takeoffFuel)
	{
		return n * (exp(distance/n / K) * emptyMass - emptyMass + takeoffFuel);
	}
	double minimizeFuel(int distance, int K, int emptyMass, int takeoffFuel) 
	{
		LL x = 1;
		LL w = (1LL<<60);
		while( w-x > 10 )
		{
			LL y = 2*x/3 + w/3;
			LL z = x/3 + 2*w/3;
			double fx = f(x, distance, K, emptyMass, takeoffFuel);
			double fy = f(y, distance, K, emptyMass, takeoffFuel);
			double fz = f(z, distance, K, emptyMass, takeoffFuel);
			double fw = f(w, distance, K, emptyMass, takeoffFuel);
			if( fx < fy )      w = y;
			else if( fz > fw ) x = z;
			else if( fy < fz ) w = z;
			else               x = y;
		}

		double fuMin = 1e+300;
		for(LL n=x; n<=w; ++n)
			fuMin = min(fuMin, f(n, distance, K, emptyMass, takeoffFuel));
		return fuMin;
	}
};

// BEGIN CUT HERE
#include <ctime>
double start_time; string timer()
 { ostringstream os; os << " (" << int((clock()-start_time)/CLOCKS_PER_SEC*1000) << " msec)"; return os.str(); }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v)
 { os << "{ ";
   for(typename vector<T>::const_iterator it=v.begin(); it!=v.end(); ++it)
   os << '\"' << *it << '\"' << (it+1==v.end() ? "" : ", "); os << " }"; return os; }
void verify_case(const double& Expected, const double& Received) {
 double diff = Expected - Received; if (diff < 0) diff = -diff; bool ok = (diff < 1e-9);
 if(ok) cerr << "PASSED" << timer() << endl;  else { cerr << "FAILED" << timer() << endl;
 cerr << "\to: \"" << Expected << '\"' << endl << "\tx: \"" << Received << '\"' << endl; } }
#define CASE(N) {cerr << "Test Case #" << N << "..." << flush; start_time=clock();
#define END	 verify_case(_, FlightScheduler().minimizeFuel(distance, K, emptyMass, takeoffFuel));}
int main(){

CASE(0)
	int distance = 40000; 
	int K = 100000; 
	int emptyMass = 150000; 
	int takeoffFuel = 5000; 
	double _ = 76420.82744805096; 
END
CASE(1)
	int distance = 40000; 
	int K = 55000; 
	int emptyMass = 150000; 
	int takeoffFuel = 5000; 
	double _ = 138450.61724934017; 
END
CASE(2)
	int distance = 1000; 
	int K = 500; 
	int emptyMass = 1000; 
	int takeoffFuel = 50; 
	double _ = 2664.9853821314487; 
END
CASE(3)
	int distance = 10000; 
	int K = 100; 
	int emptyMass = 200; 
	int takeoffFuel = 5; 
	double _ = 24635.869665316768; 
END
CASE(4)
	int distance = 140000; 
	int K = 4; 
	int emptyMass = 10000; 
	int takeoffFuel = 10; 
	double _ = 3.6576871282155204E8; 
END

}
// END CUT HERE
