Artifact Content
Not logged in

Artifact 6a80b80254e8b11117fa0e6720f8792410b661e3


#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>
#ifdef __GNUC__
#include <ext/hash_map>
#define unordered_map __gnu_cxx::hash_map
#else
#include <unordered_map>
#endif
using namespace std;
typedef long long LL;
typedef complex<double> CMP;

class MagicBlizzard { public:
	double expectation(vector <int> range, vector <int> amount)
	{
		vector< pair<int,int> > ar;
		for(int i=0; i<range.size(); ++i)
			ar.push_back(make_pair(range[i], amount[i]));

		sort(ar.begin(), ar.end());
		double total = 0.0;
		int cnt = 0;
		for(int i=0; i<ar.size(); ++i)
			for(int _=0; _<ar[i].second; ++_)
				total += 2.0 * (cnt++) / (ar[i].first*2+1) / (ar[i].first*2+1) + 1;
		return total;
	}
};

// 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(_, MagicBlizzard().expectation(range, amount));}
int main(){

CASE(0)
	int range_[] = {1,0};
	  vector <int> range(range_, range_+sizeof(range_)/sizeof(*range_)); 
	int amount_[] = {1,1};
	  vector <int> amount(amount_, amount_+sizeof(amount_)/sizeof(*amount_)); 
	double _ = 2.2222222222222223; 
END
CASE(1)
	int range_[] = {1,0};
	  vector <int> range(range_, range_+sizeof(range_)/sizeof(*range_)); 
	int amount_[] = {2,1};
	  vector <int> amount(amount_, amount_+sizeof(amount_)/sizeof(*amount_)); 
	double _ = 3.666666666666667; 
END
CASE(2)
	int range_[] = {5,2,6,5};
	  vector <int> range(range_, range_+sizeof(range_)/sizeof(*range_)); 
	int amount_[] = {1,2,2,3};
	  vector <int> amount(amount_, amount_+sizeof(amount_)/sizeof(*amount_)); 
	double _ = 8.46525111252384; 
END
CASE(3)
	int range_[] = {7,11,2,13,3,19,5,17};
	  vector <int> range(range_, range_+sizeof(range_)/sizeof(*range_)); 
	int amount_[] = {16,8,4,15,12,9,10,6};
	  vector <int> amount(amount_, amount_+sizeof(amount_)/sizeof(*amount_)); 
	double _ = 98.55659436211914; 
END
CASE(4)
	int range_[] = {0,0,0,0,0,0,0,0,0,0};
	  vector <int> range(range_, range_+sizeof(range_)/sizeof(*range_)); 
	int amount_[] = {10000,10000,10000,10000,10000,10000,10000,10000,10000,10000};
	  vector <int> amount(amount_, amount_+sizeof(amount_)/sizeof(*amount_)); 
	double _ = 1.0E10; 
END
/*
CASE(5)
	int range_[] = ;
	  vector <int> range(range_, range_+sizeof(range_)/sizeof(*range_)); 
	int amount_[] = ;
	  vector <int> amount(amount_, amount_+sizeof(amount_)/sizeof(*amount_)); 
	double _ = ; 
END
CASE(6)
	int range_[] = ;
	  vector <int> range(range_, range_+sizeof(range_)/sizeof(*range_)); 
	int amount_[] = ;
	  vector <int> amount(amount_, amount_+sizeof(amount_)/sizeof(*amount_)); 
	double _ = ; 
END
*/
}
// END CUT HERE