Cattleya number of modules (hdu1023)

#include <cstdio>
using namespace std;
const int maxn=510;
int a[maxn][maxn],b[maxn];
int n;
void catalan() //求卡特兰数
{
    int i, j, len, carry, temp;
    a[1][0] = b[1] = 1;
    len = 1;
    for(i = 2; i <= 100; i++)
    {
        for(j = 0; j < len; j++) //乘法
            A [I] [J] = A [I- . 1 ] [J] * ( . 4 * (I- . 1 ) + 2 ); 
        with Carry = 0 ;
         for (J = 0 ; J <len; J ++) // treated with multiplication result 
        { 
            TEMP = A [I] [J] + with carry; 
            A [I] [J] = TEMP% 10 ; 
            with carry = TEMP / 10 ; 
        } 
        the while (with carry) // carry process 
        { 
            A [I] [len + +] with Carry% = 10 ; 
            with Carry/ = 10 ; 
        } 
        with Carry = 0 ;
         for (J = len . 1 ; J> = 0 ; J,) // division 
        { 
            TEMP = with Carry * 10 + A [I] [J]; 
            A [I] [J ] = TEMP / (I + . 1 ); 
            with Carry = TEMP% (I + . 1 ); 
        } 
        the while (A [I] [len! . 1 ]) // high zeros 
            len - ; 
        B [I] = len; 
    } 
}
int main(){
    catalan();
    while(~scanf("%d",&n)){
        for(int i=b[n]-1;i>=0;i--){
            printf("%d",a[n][i]);
        }
        printf("\n");

    }

}
View Code

https://blog.csdn.net/wookaikaiko/article/details/81105031 number Cattleya Comments

Guess you like

Origin www.cnblogs.com/lin1874/p/11330549.html