[Killer Names](http://acm.hdu.edu.cn/showproblem.php?pid=6143)
###题解:
1.枚举一边n;
2.dp去重dp[i] = pow(i,n) - ∑dpj;
3.ans += ∑(C(m,i)×dp[i]×pow(m-i,n)%MOD);
4.记得%MOD 负数 ans = (ans%MOD+MOD)%MOD;
AC code
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <algorithm>
#include <vector>
const int maxn = 1e5 + 10;
const int MOD = 1e9 + 7;
using namespace std;
typedef long long LL;
int n,m;
LL dp[maxn];
LL C[2020][2020];
void get_C(int x)
{
C[0][0] = 1;
for(int i=1;i<=x;i++)
{
C[i][0] = 1;
for(int j=1;j<=i;j++)
C[i][j] = (C[i-1][j]+C[i-1][j-1])%MOD;
}
}
LL fpow(LL a,LL b)
{
LL ans = 1;
while(b)//用一个循环从右到左便利b的所有二进制位
{
if(b&1)//判断此时b[i]的二进制位是否为1
{
ans = (ans*a)%MOD;//乘到结果上,这里a是a^(2^i)%m
b--;//把该为变0
}
b/=2;
a = a*a%MOD;
}
return ans;
}
int main()
{
int T;
cin >> T;
get_C(2000+10);
while(T--)
{
LL ans = 0;
memset(dp,0,sizeof(dp));
scanf("%d%d",&n,&m);
dp[1] = 1;
for(int i = 2; i < m;i++)
{
dp[i] = fpow(i,n);
for(int j = 1; j < i; j++)
{
dp[i] -= (dp[j]*C[i][j]);
dp[i] = (dp[i]%MOD+MOD)%MOD;
}
}
for(int i = 1; i < m; i++)
{
dp[i] *= (C[m][i]*fpow(m-i,n)%MOD);
dp[i] %= MOD;
ans += dp[i];
ans %= MOD;
}
printf("%lld\n",ans);
}
return 0;
}