#include <stdio.h> #include <string.h> #include <iostream> #include <string> #include <queue > #include <cmath> #include <map> #include <algorithm> #include <vector>//#define Debugusing 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;}
Swust OJ 2516 coach I want to learn arithmetic dp+ combination count