计算C(2n, n)

unsigned long long C2nn(int n) {
    vector<unsigned long long>Catalan(n + 1, 0);
    Catalan[0] = 1;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j <= i; j++) {
            Catalan[i + 1] += Catalan[j] * Catalan[i - j];
        }
    }
    unsigned long long C2nn = Catalan[n] * (n + 1);
    return C2nn;
}

你可能感兴趣的:(C++常用函数及测试所用)