HDU 1465 不容易系列之一( 错排水题 )

/*************************************************************************
    > File Name: hdu1465.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

int n;
ll  d[21];

void init(){
    d[1] = 0;   d[2] = 1;
    for(int i=3;i<=20;i++)   d[i] = (i-1)*(d[i-1] + d[i-2]);
}
int main(){
    init();
    while(~scanf("%d",&n)){
	    printf("%lld\n",d[n]);
    }
    return 0;
}
posted @ 2017-04-28 16:17  ojnQ  阅读(143)  评论(0编辑  收藏  举报