题解:P17151 [ICPC 2017 Xi'an R] God of Gamblers
P17151 [ICPC 2017 Xi'an R] God of Gamblers 题解
思路
公平赌博下最终的获胜概率只和初始的资金比例有关。
父亲有
边界情况:如果
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
signed main(){
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
int n, m;
while(cin >> n >> m){
if(n == 0){
cout << fixed << setprecision(5) << 0.0 << endl;
}
else if(m == 0){
cout << fixed << setprecision(5) << 1.0 << endl;
}
else{
cout << fixed << setprecision(5) << (double)n / (n + m) << endl;
}
}
return 0;
}