Artifact Content
Not logged in

Artifact f77c6b1cfc679969df379de8471389aba08f3ab6


#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 <tuple>
using namespace std;
typedef long long LL;
typedef complex<double> CMP;

class Bitwisdom { public:
	double expectedActions(vector <int> p)
	{
		double e = 0;
		for(int i=1; i<p.size(); ++i) {
			e += (p[i]/100.0) * (100-p[i-1])/100.0
				+ (p[i-1]/100.0) * (100-p[i])/100.0;
		}
		double q = 1.0;
		for(int i=0; i<p.size(); ++i)
			q *= (p[i]/100.0);
		return e + q;
	}
};

// 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(_, Bitwisdom().expectedActions(p));}
int main(){

CASE(0)
	int p_[] = {100, 100, 100};
	  vector <int> p(p_, p_+sizeof(p_)/sizeof(*p_)); 
	double _ = 1.0; 
END
CASE(1)
	int p_[] = {50, 50};
	  vector <int> p(p_, p_+sizeof(p_)/sizeof(*p_)); 
	double _ = 0.75; 
END
CASE(2)
	int p_[] = {0, 40, 50, 60};
	  vector <int> p(p_, p_+sizeof(p_)/sizeof(*p_)); 
	double _ = 1.4; 
END
CASE(3)
	int p_[] = {37, 63, 23, 94, 12};
	  vector <int> p(p_, p_+sizeof(p_)/sizeof(*p_)); 
	double _ = 2.6820475464; 
END
/*
CASE(4)
	int p_[] = ;
	  vector <int> p(p_, p_+sizeof(p_)/sizeof(*p_)); 
	double _ = ; 
END
CASE(5)
	int p_[] = ;
	  vector <int> p(p_, p_+sizeof(p_)/sizeof(*p_)); 
	double _ = ; 
END
*/
}
// END CUT HERE