#include<cstdio>
#include<iostream>
#define LL long long
#define maxn 4000005
using namespace std;
int N=4000000;
LL mod=1e9+7;
LL fac[maxn],inv[maxn];
LL pow(LL x,int y)
{
if(y==0) return 1;
if(y==1) return x;
LL a=pow(x,y/2);
a=(a*a)%mod;
if(y%2) return (a*x)%mod;
return a;
}
void init()
{
fac[0]=1;
for(int i=1;i<=N;i++)
fac[i]=(fac[i-1]*i)%mod;
inv[N]=pow(fac[N],mod-2)%mod;
for(int i=N-1;i>=1;i--)
inv[i]=(inv[i+1]*(i+1))%mod;
inv[0]=1;
}
LL calc(int n,int m)
{
if(n<0) return 0;
n>>=1;m--;
LL ans=fac[m+n];
ans*=inv[m];ans%=mod;
ans*=inv[n];ans%=mod;
return ans;
}
int main()
{
init();
int n,m;
scanf("%d%d",&n,&m);
LL ans=0;
if(n&&m) ans++;
m=min(n,m);
for(int i=2;i<=m;i++)
{
ans+=calc(n-i,i);
ans+=calc(n-i-1,i);ans%=mod;
}
cout<<(ans%mod)<<endl;
}
bzoj 4402 Claris的剑 组合数学
最新推荐文章于 2019-10-01 23:53:09 发布