#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9+7;
const int N = 2e3+10;
typedef long long ll;
ll fac[N];
ll inv[N];
ll qpow(ll a,ll b,ll p)
{
if(b<0)return 0;
ll res= 1;
for(;b;b>>=1)
{
if(b&1)
{
res = res*a%mod;
}
a = a*a%mod;
}
return res;
}
ll C(ll n,ll m)
{
if(n<m)return 0;
return fac[n]*inv[m]%mod*inv[n-m]%mod;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
fac[0]=inv[0]=1;
for(int i=1;i<=1001;i++)
{
fac[i]=fac[i-1]*i%mod;
inv[i] = qpow(fac[i],mod-2,mod);
}
ll x,y;
cin>>x>>y;
if(x!=0&&y!=0)
{
cout<<0<<'\n';
}
else cout<<1<<'\n';
for(int i=2;i<=x+y;i++)
{
ll res = 0;
if(i%2==0)
{
ll cur = C(2,1)%mod*C(x-1,i/2-1)%mod*C(y-1,i/2-1)%mod;
res = (res+cur)%mod;
}
else
{
ll cur = C(x-1,i/2-1)%mod*C(y-1,i/2)%mod;
res =(res+cur)%mod;
cur = C(x-1,i/2)%mod*C(y-1,i/2-1)%mod;
res = (res+cur)%mod;
}
cout<<res<<'\n';
}
return 0;
}
不错的一个排列问题

京公网安备 11010502036488号