转载请注明出处,谢谢http://blog.csdn.net/ZEROcmm?viewmode=contents by---ZEROm
http://acm.hdu.edu.cn/showproblem.php?pid=4535
这题就是个错排公式
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
#define mod 1000000007
__int64 M[105];
int main()
{
M[1]=0,M[2]=1;
for(int i=3;i<=100;++i)
M[i]=((i-1)*(M[i-2]+M[i-1]))%mod;
int t;
scanf("%d",&t);
while(t--)
{
int n;
scanf("%d",&n);
printf("%I64d\n",M[n]%mod);
}
return 0;
}