当前位置:编程学习 > html/css >>

Cows and Cars

题意:给你三个整数,分别代表,cow的数目,car的数目,door的数目,情景为:玩一个游戏,初始时你选择一条门,判断门后是不是为car,但是主持人不会开门,让你选择时候改变选择,当你确认后,再打开门抽中car的概率;
 
A、当第一次选择时为cow,那么概率为cow / ( cow + car ) * car / ( cow + car - door - 1 )。这里是当且仅当打开最后一条门时;
 
B、当第一次选择时为car , 那么概率为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; }

 


补充:web前端 , HTML/CSS  ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,