Artifact Content
Not logged in

Artifact 7c6bd3238ef8c0b3a77e9ab3f5283180073a160d


#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 LotteryPyaterochka { public:
	double chanceToWin(int N_) 
	{
		LL N = N_;
		LL n5 = N;
		LL n4 = N*5*(N-1)*5;
		LL n32 = N*10*(N-1)*10;
		LL n311 = N*10*((N-1)*(N-2)/2)*5*5;
		LL all = (5*N)*(5*N-1)*(5*N-2)*(5*N-3)*(5*N-4)/120;
		return double(n5+n4+n32+n311) / all;
	}
};

// 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(_, LotteryPyaterochka().chanceToWin(N));}
int main(){

CASE(0)
	int N = 1; 
	double _ = 1.0; 
END
CASE(1)
	int N = 2; 
	double _ = 1.0; 
END
CASE(2)
	int N = 3; 
	double _ = 0.5004995004995004; 
END
CASE(3)
	int N = 6; 
	double _ = 0.13161551092585574; 
END
CASE(4)
	int N = 99; 
	double _ = -1; 
END
CASE(5)
	int N = 100; 
	double _ = -1; 
END

}
// END CUT HERE