Bonus Cards
概率dp。
#include<bits/stdc++.h>
#define cin fin
#define cout fout
using namespace std;
ifstream fin("bonus.in");
ofstream fout("bonus.out");
double f[3009][3009]/*= {1}*/;//去掉注释会因为生成文件过大而过不了编译?
double dp(int n,int a,int b,int c)
{
for(int i=f[0][0]=1; i<=n; ++i)
for(int j=0; j<=i; ++j)
{
f[i][j]=0;
if(a-j+1>0&&b-i+j>=0)f[i][j]+=2*(a-j+1)/(2.0*(a-j+1)+b-i+j+c)*f[i-1][j-1];
if(a-j>=0&&b-i+j+1>0)f[i][j]+=(b-i+j+1)/(2.0*(a-j)+b-i+j+1+c)*f[i-1][j];
}
return accumulate(f[n],f[n]+min(a,n)+1,0.0);
}
int main()
{
int n,a,b;
cin>>n>>a>>b;
cout.precision(9);
cout<<1-dp(n,a,b,2