链接:传送门
思路:错排模板题,水题是非常浪费时间的。
/*************************************************************************
> File Name: hdu4535.cpp
> Author: WArobot
> Blog: http://www.cnblogs.com/WArobot/
> Created Time: 2017年04月28日 星期五 15时30分45秒
************************************************************************/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
int n , t;
ll d[101];
void init(){
d[1] = 0; d[2] = 1;
for(int i=3;i<=100;i++){
d[i] = (i-1)*(d[i-1] + d[i-2]);
d[i] %= mod;
}
}
int main(){
init();
scanf("%d",&t);
while(t--){
scanf("%d",&n);
printf("%lld
",d[n]);
}
return 0;
}