Question: Here are three integers, which respectively represent the number of cow, the number of cars, and the number of doors. The scenario is: play a game. You should select a door at first, judge whether the door is behind the car, but the host does not open the door, let you choose to change the choice, when you confirm, then re-open the door to draw the probability of the car; A, when the first selection for cow, the probability is cow/(cow + car) * car/(cow + car-door-1 ). Here is when and only when the last door is opened; B. When the first choice is car, the probability is car/(cow + car) * (car-1) /(cow + car-door-1 );
#include<map> #include<set> #include<list> #include<cmath> #include<ctime> #include<deque> #include<stack> #include<bitset> #include<cstdio> #include<vector> #include<cstdlib> #include<cstring> #include<iomanip> #include<numeric> #include<sstream> #include<utility> #include<iostream> #include<algorithm> #include<functional> using namespace std ; int main() { double cow , car , door ; while( cin >> cow >> car >> door ) cout << setprecision( 5 ) << fixed << ( cow + car - 1 ) * car / (( cow + car ) * ( cow + car - door - 1 ) ) << endl ; return 0; }