[CF98E]Help Shrek and Donkey(纳什均衡)

时间:2023-03-09 22:34:17
[CF98E]Help Shrek and Donkey(纳什均衡)

https://www.cnblogs.com/MashiroSky/p/6576398.html

 #include<cstdio>
#include<algorithm>
#define rep(i,l,r) for (int i=(l); i<=(r); i++)
using namespace std; const int N=;
int n,m;
double g[N][N]; double f(int n,int m){
if (!n) return ./(m+);
if (!m) return .;
if (g[n][m]) return g[n][m];
double A=(-(f(m-,n)))*m/(m+),B=(-f(m-,n))*m/(m+)+./(m+);
double C=-f(m,n-),p=(C-)/(A-B+C-);
return g[n][m]=p*A+(-p);
} int main(){
freopen("CF98E.in","r",stdin);
freopen("CF98E.out","w",stdout);
scanf("%d%d",&n,&m); printf("%.10lf %.10lf\n",f(n,m),-f(n,m));
return ;
}