Skip to content

Instantly share code, notes, and snippets.

@miaout17
Created June 19, 2011 02:44
Show Gist options
  • Save miaout17/1033694 to your computer and use it in GitHub Desktop.
Save miaout17/1033694 to your computer and use it in GitHub Desktop.
TCO11-R1-500.cpp
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i,a,b) for (int i=int(a); i<int(b); ++i)
class MuddyRoad {
public:
double getExpectedValue(vector <int>);
};
double MuddyRoad::getExpectedValue(vector <int> road) {
double dirty = 0.0, ans = 0.0;
REP(i, 1, road.size()-1) {
double muddy = double(road[i]) / 100.0;
ans += dirty * muddy;
dirty = (1.0-dirty) * muddy;
}
return ans;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment