提交时间:2023-10-05 08:22:14

运行 ID: 105023

#include<iostream> using namespace std; long long a[25]; int main() { int n; cin >> n; a[1] = 0; a[2] = 1; for(int i = 3;i <= n;i++) { a[i] = (i - 1) * (a[i - 1] + a[i - 2]); } cout << a[n] << endl; return 0; }