1 #include <bits/stdc++.h> 2 #define pb push_back 3 #define _for(i,a,b) for(int i = (a);i < (b);i ++) 4 #define INF 0x3f3f3f3f 5 6 using namespace std; 7 8 const int maxn = 5003; 9 10 long long solve(long long n) 11 { 12 if(n==1) 13 return 0; 14 else if(n==2) 15 return 1; 16 17 return (n-1)*(solve(n-1)+solve(n-2)); 18 } 19 20 int main() 21 { 22 int N; 23 while(~scanf("%d",&N)) 24 { 25 cout << solve(N) << endl; 26 } 27 return 0; 28 }