#include <iostream> #include <algorithm> #include <cstdio> using namespace std; typedef long long LL; const LL N=2e6;// 题目太坑了 提交 1e6会莫名错误 const LL mod=1e9+7; LL f[N+7]; LL inv_f[N+7]; LL n,m,k; LL q_pow (LL x,LL k) {//快速幂求逆元 LL ans=1; while (k) { if (k&1) ans=ans*x%mod; x=x*x%mod; k=(k>>1); } return ans%mod; } LL C (LL n, LL m) {// C(n,m)=n!/(m!*(n-m)!) if (n<m) return 0; LL t1=f[n]; LL t2=inv_f[n-m]*inv_f[m]%mod; return t1*t2%mod; } int main () { f[0]=1; for (int i=1;i<=N;i++) f[i]=f[i-1]*i%mod;// f[n]=n! inv_f[N]=q_pow(f[N],mod-2); for (int i=N-1;i>=0;i--) inv_f[i]=inv_f[i+1]*(i+1)%mod; // inv_f[i]=1/(n!); (逆元) while (cin>>n>>m>>k) { LL ans=C (m+n-1,n-1);// 组合数学多重集合挑选元素 LL t=-1; LL num=m-(k+1); for (int i=1;num>=0&&i<=n;i++,t=-t,num-=(k+1)) { LL tmp=C(n,i)*C(num+n-1,n-1)%mod;// 容斥原理 ans=(ans+t*tmp+mod)%mod; } cout<<ans<<endl; } return 0; }