Educational Codeforces Round 80 (Div. 2) C. Two Arrays ( dp )

題目

Educational Codeforces Round 80 (Div. 2) C. Two Arrays

思路

https://www.cnblogs.com/Herlo/p/12195658.html

代碼

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
ll num[30][2000];
ll n, m;
ll dp(int i, int last)
{
    if(i == m)
        return 1;
    ll &ans = num[i][last];//引用
    printf("%d\n", ans);
    if(ans)
        return ans;
    for(int j = last; j <= n; j++)
    {
        ans += dp(i + 1, j) % mod;
    }
    return ans % mod;
}
int main()
{
    cin >> n >> m;
    m <<= 1;
    cout << dp(0, 1) % mod << endl;
    return 0;
}
發佈了184 篇原創文章 · 獲贊 24 · 訪問量 2萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章