1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | #include <stdio.h> #define N 12 int n; int dp[N + 1]; int main() { scanf("%d", &n); // dp[n] = (n - 1) * (dp[n - 2] + dp[n - 1]) dp[2] = 1; for (int i = 3; i <= N; i++) dp[i] = (i - 1) * (dp[i - 2] + dp[i - 1]); printf("%d\n", dp[n]); return 0; } | cs |
Dovelet
- 완전 순열 2015.11.17
완전 순열
2015. 11. 17. 01:02