Author: loop3r
Date: 20260314
tag: 递推
link: https://www.luogu.com.cn/problem/P1595问题描述
分析
略
参考代码
cpp
#include <bits/stdc++.h>
using namespace std;
int n;
long long f[25];
int main() {
cin >> n;
f[1] = 0;
f[2] = 1;
for (int i = 3; i <= n; i++) {
f[i] = (i - 1) * (f[i - 1] + f[i - 2]);
}
cout << f[n] << endl;
return 0;
}