c_cpp https://arena.topcoder.com/#/u/practiceCode/12244/7853/8776/2/270168

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了c_cpp https://arena.topcoder.com/#/u/practiceCode/12244/7853/8776/2/270168相关的知识,希望对你有一定的参考价值。

#include <bits/stdc++.h>

#define ll long long
#define sz(v) ((int) ((v).size()))
#define clr(v, d) memset(v, d, sizeof(v))
#define lp(i, n) for(int i = 0; i < (int)(n); ++i)
#define rep(i, v) for(int i = 0; i < sz(v); ++i)

using namespace std;

const int MAX = 35;
const int OO = 1e9;

int n;
ll cache[MAX][MAX];

ll fd(int i, int level) {
    //cout << i << " " << level << endl;
    if(i == n) {
        //cout << "END : " << i << "  " << level << endl;
        return 1;
    }

    ll &ret = cache[i][level];
    if(ret != -1)
        return ret;

    ret = 0;
    int k = 0;
    if(i == 0)
        k++;
    for(; k <= n-i && k <= level; k++) {
        ret += fd(i+1, k);
    }

    return ret;
}
/*
int main() {
    clr(cache, -1);
    cin>>n;
    cout << fd(0, n) <<endl;
    return 0;
}*/


class FIELDDiagrams {
public:
    ll countDiagrams(int n1) {
        clr(cache, -1);
        n = n1;
        return fd(0, n);
    }
};

以上是关于c_cpp https://arena.topcoder.com/#/u/practiceCode/12244/7853/8776/2/270168的主要内容,如果未能解决你的问题,请参考以下文章

c_cpp 127.单词阶梯

c_cpp MOFSET

c_cpp MOFSET

c_cpp 31.下一个排列

c_cpp string→char *

c_cpp 54.螺旋矩阵