HDU 4535 吉哥系列故事——礼尚往来( 错排水题 )

/*************************************************************************
    > 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\n",d[n]);
	}
    return 0;
}
posted @ 2017-04-28 16:27  ojnQ  阅读(109)  评论(0编辑  收藏  举报