text: // File Name: 1000.cpp
  // Author: YangYue
  // Created Time: Tue Jul 22 19:50:15 2014
  //headers 
  #include <cstdio>
  #include <cstdlib>
  #include <cstring>
  #include <algorithm>
  #include <cstring>
  #include <cmath>
  #include <ctime>
  #include <string>
  #include <queue>
  #include <set>
  #include <map>
  #include <iostream>
  #include <vector>
  
  using namespace std;
  
  typedef long long LL;
  typedef unsigned long long ULL;
  typedef pair<int,int> PII;
  typedef pair<double,double> PDD;
  typedef pair<LL, LL>PLL;
  typedef pair<LL,int>PLI;
  
  #define lch(n) ((n<<1))
  #define rch(n) ((n<<1)+1)
  #define lowbit(i) (i&-i)
  #define sqr(x) ((x)*(x))
  #define fi first
  #define se second
  #define MP make_pair
  #define PB push_back
  
  const int MaxN = 1000005;
  const double eps = 1e-8;
  const double DINF = 1e100;
  const int INF = 1000000006;
  const LL LINF = 1000000000000000005ll;
  
  class DoraemonPuzzleGame {
  public:
  	double f[2005][2005];
  	double px[2005], py[2005], pz[2005];
  	void update(double &x, double v) {
  		if (x == -1) x = v;
  		else x += v;
  	}
  	double solve(vector <int> X, vector <int> Y, int m) {
  		int n = X.size();
  		double res = 0;
  		for (int i = 0; i < n; ++i) {
  			px[i] = X[i] / 1000.;
  			py[i] = Y[i] / 1000.;
  			pz[i] = (1 - px[i] - py[i]);
  			px[i] = 1 / px[i];
  			py[i] = 1 / py[i];
  		}
  		for (int i = 0; i < m; ++i) f[n][i] = -1;
  		for (int i = n - 1; i >= 0; --i) {
  			for (int j = 0; j <= 2*n; ++j) {
  				if (f[i+1][j+1] >= 0) update(f[i][j], f[i+1][j+1] + px[i]);
  				if (f[i+1][j+2] >= 0) update(f[i][j], f[i+1][j+2] + py[i]);
  			}
  		}
  		return f[0][0];
  	}
  };
  // BEGIN KAWIGIEDIT TESTING
  // Generated by KawigiEdit 2.1.4 (beta) modified by pivanof
  bool KawigiEdit_RunTest(int testNum, vector <int> p0, vector <int> p1, int p2, bool hasAnswer, double p3) {
  	cout << "Test " << testNum << ": [" << "{";
  	for (int i = 0; int(p0.size()) > i; ++i) {
  		if (i > 0) {
  			cout << ",";
  		}
  		cout << p0[i];
  	}
  	cout << "}" << "," << "{";
  	for (int i = 0; int(p1.size()) > i; ++i) {
  		if (i > 0) {
  			cout << ",";
  		}
  		cout << p1[i];
  	}
  	cout << "}" << "," << p2;
  	cout << "]" << endl;
  	DoraemonPuzzleGame *obj;
  	double answer;
  	obj = new DoraemonPuzzleGame();
  	clock_t startTime = clock();
  	answer = obj->solve(p0, p1, p2);
  	clock_t endTime = clock();
  	delete obj;
  	bool res;
  	res = true;
  	cout << "Time: " << double(endTime - startTime) / CLOCKS_PER_SEC << " seconds" << endl;
  	if (hasAnswer) {
  		cout << "Desired answer:" << endl;
  		cout << "\t" << p3 << endl;
  	}
  	cout << "Your answer:" << endl;
  	cout << "\t" << answer << endl;
  	if (hasAnswer) {
  		res = fabs(p3 - answer) <= 1e-9 * max(1.0, fabs(p3));
  	}
  	if (!res) {
  		cout << "DOESN'T MATCH!!!!" << endl;
  	} else if (double(endTime - startTime) / CLOCKS_PER_SEC >= 2) {
  		cout << "FAIL the timeout" << endl;
  		res = false;
  	} else if (hasAnswer) {
  		cout << "Match :-)" << endl;
  	} else {
  		cout << "OK, but is it right?" << endl;
  	}
  	cout << "" << endl;
  	return res;
  }
  int main() {
  	bool all_right;
  	all_right = true;
  	
  	vector <int> p0;
  	vector <int> p1;
  	int p2;
  	double p3;
  	
  	{
  	// ----- test 0 -----
  	int t0[] = {800};
  			p0.assign(t0, t0 + sizeof(t0) / sizeof(t0[0]));
  	int t1[] = {200};
  			p1.assign(t1, t1 + sizeof(t1) / sizeof(t1[0]));
  	p2 = 2;
  	p3 = 5.0;
  	all_right = KawigiEdit_RunTest(0, p0, p1, p2, true, p3) && all_right;
  	// ------------------
  	}
  	
  	{
  	// ----- test 1 -----
  	int t0[] = {1,999,999};
  			p0.assign(t0, t0 + sizeof(t0) / sizeof(t0[0]));
  	int t1[] = {999,1,1};
  			p1.assign(t1, t1 + sizeof(t1) / sizeof(t1[0]));
  	p2 = 3;
  	p3 = 3.0;
  	all_right = KawigiEdit_RunTest(1, p0, p1, p2, true, p3) && all_right;
  	// ------------------
  	}
  	
  	{
  	// ----- test 2 -----
  	int t0[] = {500,500};
  			p0.assign(t0, t0 + sizeof(t0) / sizeof(t0[0]));
  	int t1[] = {500,500};
  			p1.assign(t1, t1 + sizeof(t1) / sizeof(t1[0]));
  	p2 = 3;
  	p3 = 2.5;
  	all_right = KawigiEdit_RunTest(2, p0, p1, p2, true, p3) && all_right;
  	// ------------------
  	}
  	
  	{
  	// ----- test 3 -----
  	int t0[] = {250,250,250,250};
  			p0.assign(t0, t0 + sizeof(t0) / sizeof(t0[0]));
  	int t1[] = {250,250,250,250};
  			p1.assign(t1, t1 + sizeof(t1) / sizeof(t1[0]));
  	p2 = 5;
  	p3 = 8.25;
  	all_right = KawigiEdit_RunTest(3, p0, p1, p2, true, p3) && all_right;
  	// ------------------
  	}
  	
  	{
  	// ----- test 4 -----
  	int t0[] = {250,500,250};
  			p0.assign(t0, t0 + sizeof(t0) / sizeof(t0[0]));
  	int t1[] = {500,250,500};
  			p1.assign(t1, t1 + sizeof(t1) / sizeof(t1[0]));
  	p2 = 5;
  	p3 = 4.962962962962963;
  	all_right = KawigiEdit_RunTest(4, p0, p1, p2, true, p3) && all_right;
  	// ------------------
  	}
  	
  	{
  	// ----- test 5 -----
  	int t0[] = {600,900,800,500,900,200,400,100,800,300,900,300,800,700,800,600,800,900,400,100,100,700,600,100,500,800,700,600,900,600,300,100,300,100,700,500,900,200,800,400,300,700,300,400,700,300,400,800,300,200};
  			p0.assign(t0, t0 + sizeof(t0) / sizeof(t0[0]));
  	int t1[] = {400,100,200,500,100,800,600,900,200,700,100,700,200,300,200,400,200,100,600,900,900,300,400,900,500,200,300,400,100,400,700,900,700,900,300,500,100,800,200,600,700,300,700,600,300,700,600,200,700,800};
  			p1.assign(t1, t1 + sizeof(t1) / sizeof(t1[0]));
  	p2 = 95;
  	p3 = 119.33578280666175;
  	all_right = KawigiEdit_RunTest(5, p0, p1, p2, true, p3) && all_right;
  	// ------------------
  	}
  	
  	if (all_right) {
  		cout << "You're a stud (at least on the example cases)!" << endl;
  	} else {
  		cout << "Some of the test cases had errors." << endl;
  	}
  	return 0;
  }
  // END KAWIGIEDIT TESTING
  // hehe ~
  
  
  