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
",d[n]);
    }
    return 0;
}
原文地址:https://www.cnblogs.com/WArobot/p/6782069.html