P1044 [NOIP2003 普及组] 栈

题目链接:https://www.luogu.com.cn/problem/P1044

数论的应用,卡特尔数和组合数学的应用,算是纯数学题

代码及其注意事项如下:

#include<bits/stdc++.h>
using namespace std;
int n;
long long a[9000][9000];
int main()
{
    ios::sync_with_stdio(false);
    cin>>n;
    for(register int i=1;i<=2*n;i++)
    {
         a[i][0]=a[i][i]=1;//特殊情况处理 ,不要忘了特殊处理 
         for(register int j=1;j<i;j++)
         {
             a[i][j]=a[i-1][j-1]+a[i-1][j];//组合数学的递推公式 
         }
    }
    cout<<(a[2*n][n]/(n+1))<<endl;//卡特尔数,组合数学 
    return 0;
}

 

posted @ 2022-03-23 20:34  江上舟摇  阅读(42)  评论(0编辑  收藏  举报