提交时间:2022-07-20 11:50:58
运行 ID: 52711
#include<cstdio> typedef long long ll; const ll mod=1e9+7; int n,m,k; ll ans; ll t[5005]; ll vis; inline void dfs(int now,int lst,int used){ if(now==k){ ans+=t[n-used]; ans%=mod; vis=(vis+1)%mod; return; } for(int i=lst;i*(k-now+1)<=n-used;++i){ ll g=vis; dfs(now+1,i,used+i); ans+=t[i]*(vis-g+mod)%mod; ans%=mod; } } inline ll fp(ll x,int y){ ll s=1; while(y){ if(y&1) s=s*x%mod; x=x*x%mod; y>>=1; } return s; } int main(){ scanf("%d%d%d",&n,&k,&m); for(ll i=1;i<=n;++i) t[i]=fp(i,m); if(k==n){ printf("%d\n",n); return 0; } dfs(1,1,0); printf("%lld\n",ans); return 0; }