题解:P17151 [ICPC 2017 Xi'an R] God of Gamblers
a_small_OIer · · 题解
P17151 [ICPC 2017 Xi'an R] God of Gamblers
简单结论题。
题意简述
父亲与老人赌博,父亲初始有
思路
我们注意到:无论采用何种下注策略,只要每次下注的期望收益为零(公平赌局),则最终破产概率只取决于初始资金占总资金的比例,且为
::::info[证明]
每一局中,父亲下注金额为
又因为整个游戏是公平的,总期望收益为
设父亲获胜概率为
解得:
::::
因此答案与具体策略无关,直接输出
时间复杂度:
code
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
//十年OI一场空,不开long long见祖宗
int T , n , m;
int main(){
while(scanf("%d" , &n) != EOF){
scanf("%d" , &m);
printf("%.5lf\n" , 1.0 * n / (m + n));
}
return 0;
}