HDU 1456 错排

递推DP

大佬讲解

//MADE BY Y_is_sunshine;
//#include <bits/stdc++.h>
//#include <memory.h>
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <cstdio>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <math.h>

#define INF 0x3f3f3f3f
#define MAXN 105

const int mod = 1e9 + 7;

using namespace std;

long long d[25];

int main()
{
	freopen("data.txt", "r", stdin);

	d[2] = 1;
	d[3] = 2;
	for (int i = 4; i <= 20; i++)
		d[i] = (i - 1) * (d[i - 1] + d[i - 2]);
	int N;
	while (cin >> N)
		cout << d[N] << endl;
	

	freopen("CON", "r", stdin);
	system("pause");
	return 0;
}
全部评论

相关推荐

今天 11:53
门头沟学院 Java
点赞 评论 收藏
分享
07-15 00:33
江苏大学 Java
代码飞升:哈哈哈哈评论区三个打广告的
简历中的项目经历要怎么写
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务