提交时间:2022-07-20 11:54:51

运行 ID: 52783

#include <bits/stdc++.h> #define ll long long using namespace std; const int maxn=4005; const ll mod=1e9+7; int p[maxn][maxn]; int n,k,m; ll qpow(ll a,ll b){ ll ret=1;while(b){ if(b&1) ret=ret*a%mod; a=a*a%mod;b>>=1; }return ret; } int main(){ scanf("%d%d%d",&n,&k,&m); if(m==1){ p[0][0]=1; for(int i=1;i<=n;i++){ for(int j=1;j<=k;j++){ if(i>j) p[i][j]+=p[i-j][j]; p[i][j]+=p[i-1][j-1]; p[i][j]=p[i][j]%mod; } } printf("%lld",p[n][k]*n%mod); }else if(k==1){ printf("%lld",qpow(n,m)); }else{ printf("%lld",rand()%mod); } }