分析
代码
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<ctime>
#include<vector>
#include<set>
#include<map>
#include<stack>
using namespace std;
const int mod = 1e9+7;
int k,x,y,dp[2010][2010];
inline int pw(int a,int p){
int res=1;
while(p){
if(p&1)res=1ll*res*a%mod;
a=1ll*a*a%mod;
p>>=1;
}
return res;
}
inline int go(int i,int j){
if(i+j>=k)return dp[i][j]=(i+j+1ll*x*pw(y,mod-2)%mod)%mod;
if(dp[i][j]!=-1)return dp[i][j];
dp[i][j]=1ll*(1ll*go(i+1,j)*x%mod+1ll*go(i,j+i)*y%mod)*pw(x+y,mod-2)%mod;
return dp[i][j];
}
int main(){
cin>>k>>x>>y;
memset(dp,-1,sizeof(dp));
cout<<go(1,0);
return 0;
}