Artifact Content
Not logged in

Artifact d3ffed894b1fce357bb961b7b9f8231cfc2a5275


#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 FoxPlayingGame { public:
	double theMax(int nA, int nB, int paramA, int paramB) 
	{
		double scoreA = paramA / 1000.0;
		double scoreB = paramB / 1000.0;

		double cur=scoreA*nA, best=cur;
		for(int i=0; i<=nB; ++i,cur*=scoreB)
		   best = max(best, cur);
		return best;
	}
};

// 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) {
 bool ok = (abs(Expected - Received) < 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(_, FoxPlayingGame().theMax(nA, nB, paramA, paramB));}
int main(){

CASE(0)
	int nA = 5; 
	int nB = 4; 
	int paramA = 3000; 
	int paramB = 2000; 
	double _ = 240.0; 
END
CASE(1)
	int nA = 3; 
	int nB = 3; 
	int paramA = 2000; 
	int paramB = 100; 
	double _ = 6.0; 
END
CASE(2)
	int nA = 4; 
	int nB = 3; 
	int paramA = -2000; 
	int paramB = 2000; 
	double _ = -8.0; 
END
CASE(3)
	int nA = 5; 
	int nB = 5; 
	int paramA = 2000; 
	int paramB = -2000; 
	double _ = 160.0; 
END
CASE(4)
	int nA = 50; 
	int nB = 50; 
	int paramA = 10000; 
	int paramB = 2000; 
	double _ = 5.62949953421312E17; 
END
CASE(5)
	int nA = 41; 
	int nB = 34; 
	int paramA = 9876; 
	int paramB = -1234; 
	double _ = 515323.9982341775; 
END
CASE(6)
	int nA = 23;
	int nB = 34; 
	int paramA = -9422; 
	int paramB = -180; 
	double _ = 39.00708; 
END
/*
CASE(7)
	int nA = ; 
	int nB = ; 
	int paramA = ; 
	int paramB = ; 
	double _ = ; 
END
*/
}
// END CUT HERE