Artifact Content
Not logged in

Artifact 2978fcbee76e9eafb24b38fac03f1cb1f436810b


#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 TheLotteryBothDivs { public:
	double find(vector <string> goodSuffixes) 
	{
		sort(goodSuffixes.begin(), goodSuffixes.end());
		goodSuffixes.erase(unique(goodSuffixes.begin(), goodSuffixes.end()), goodSuffixes.end());
		double p = 0.0;
		for(int i=0; i<goodSuffixes.size(); ++i) {
			const string& me = goodSuffixes[i];
			bool use = true;
			for(int k=0; k<goodSuffixes.size(); ++k)
				if( is_proper_suffix(me, goodSuffixes[k]) )
					use = false;
			if( use )
				p += pow(0.1, (double)me.size());
		}
		return p;
	}
	bool is_proper_suffix(const string& me, const string& suf)
	{
		if( me.size() <= suf.size() )
			return false;
		return me.substr(me.size()-suf.size()) == suf;
	}
};

// 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(_, TheLotteryBothDivs().find(goodSuffixes));}
int main(){

CASE(0)
	string goodSuffixes_[] = {"4"};
	  vector <string> goodSuffixes(goodSuffixes_, goodSuffixes_+sizeof(goodSuffixes_)/sizeof(*goodSuffixes_)); 
	double _ = 0.1; 
END
CASE(1)
	string goodSuffixes_[] = {"4", "7"};
	  vector <string> goodSuffixes(goodSuffixes_, goodSuffixes_+sizeof(goodSuffixes_)/sizeof(*goodSuffixes_)); 
	double _ = 0.2; 
END
CASE(2)
	string goodSuffixes_[] = {"47", "47"};
	  vector <string> goodSuffixes(goodSuffixes_, goodSuffixes_+sizeof(goodSuffixes_)/sizeof(*goodSuffixes_)); 
	double _ = 0.01; 
END
CASE(3)
	string goodSuffixes_[] = {"47", "58", "4747", "502"};
	  vector <string> goodSuffixes(goodSuffixes_, goodSuffixes_+sizeof(goodSuffixes_)/sizeof(*goodSuffixes_)); 
	double _ = 0.021; 
END
CASE(4)
	string goodSuffixes_[] = {"8542861", "1954", "6", "523", "000000000", "5426", "8"};
	  vector <string> goodSuffixes(goodSuffixes_, goodSuffixes_+sizeof(goodSuffixes_)/sizeof(*goodSuffixes_)); 
	double _ = 0.201100101; 
END
/*
CASE(5)
	string goodSuffixes_[] = ;
	  vector <string> goodSuffixes(goodSuffixes_, goodSuffixes_+sizeof(goodSuffixes_)/sizeof(*goodSuffixes_)); 
	double _ = ; 
END
CASE(6)
	string goodSuffixes_[] = ;
	  vector <string> goodSuffixes(goodSuffixes_, goodSuffixes_+sizeof(goodSuffixes_)/sizeof(*goodSuffixes_)); 
	double _ = ; 
END
*/
}
// END CUT HERE