标签:style blog class code tar c
#include <stdio.h> #include <string.h> #include <stdlib.h> #include <algorithm> using namespace std; long long C(long long n, long long m) { double ans = 1; for (int i = 0; i < m; i++) { ans *= n - i; } for (int i = 0; i < m; i++) ans /= i + 1; return (long long)(ans + 0.5); } const int N = 31; int n; long long f[N]; long long dp[N][N]; int main() { f[1] = 1; for (int i = 0; i < N; i++) dp[i][0] = 1; for (int i = 1; i < N; i++) {dp[i][1] = 1; dp[0][i] = 0;} for (int i = 1; i < N; i++) { for (int j = 2; j < N; j++) { dp[i][j] = 0; for (int p = 0; p * i <= j; p++) { dp[i][j] += C(f[i] + p - 1, p) * dp[i - 1][j - p * i]; } } f[i + 1] = dp[i][i + 1]; } while (~scanf("%d", &n) && n) { printf("%lld\n", n == 1 ? 1 : 2 * f[n]); } system("pause"); return 0; }
UVA 10253 - Series-Parallel Networks(数论+计数问题+递推),布布扣,bubuko.com
UVA 10253 - Series-Parallel Networks(数论+计数问题+递推)
标签:style blog class code tar c
原文地址:http://blog.csdn.net/accelerator_/article/details/25475511