Created
June 19, 2011 02:44
-
-
Save miaout17/1033694 to your computer and use it in GitHub Desktop.
TCO11-R1-500.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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