标签:
#include<stdio.h> #include<string.h> #include<iostream> #include<string> #include<queue> #include<cmath> #include<map> #include<algorithm> #include<vector> //#define debug using namespace std; const int inf = 0x3fffffff; const int mod = 1000000007; const int mmax = 1000010; typedef long long LL; int n,m,k; LL inv[mmax]; LL jie[mmax]; LL dp[1100]; void pre() { inv[0]=inv[1]=1; jie[0]=jie[1]=1; for(int i=2;i<mmax;i++) { inv[i]=(LL)(mod-mod/i)*inv[mod%i]%mod; jie[i]=jie[i-1]*i; jie[i]%=mod; } for(int i=2;i<mmax;i++) { inv[i]*=inv[i-1]; inv[i]%=mod; } } LL Pow_mod(LL x ,int n) { LL res=1,tmp=x; for(;n;n/=2) { if(n&1) res=(res*tmp)%mod; tmp=(tmp*tmp)%mod; } return res; } LL C(int x,int y) { if(y>x) return 0; return jie[x]*inv[y]%mod*inv[x-y]%mod; } void build() { dp[0]=0; dp[1]=1; for(int i=2;i<=n;i++) { dp[i]=Pow_mod(i,n); for(int j=1;j<i;j++) { dp[i]-=dp[i-j]*C(i,j)%mod; dp[i]=(dp[i]%mod+mod)%mod; } } } int main() { pre(); while(~scanf("%d %d %d",&n,&m,&k)) { if(m==1) { printf("%lld\n",Pow_mod(k,n)); continue; } build(); LL cnt=0; for(int i=0;i<=n;i++) { for(int j=0;i+j<=n;j++) { LL tmp=1; tmp=C(k,i)*C(k-i,j)%mod*C(k-i-j,j)%mod; tmp*=dp[i+j]*dp[i+j]%mod*Pow_mod((LL)i,n*(m-2))%mod; tmp%=mod; cnt+=tmp; cnt%=mod; } } printf("%lld\n",cnt); } return 0; }
标签:
原文地址:http://blog.csdn.net/u012127882/article/details/46417365