Categorías
Otros

Código Carterland

Aplicación

1. Pregunte a un árbol binario (aumentando un nodo, cuántos árboles binarios se pueden hacer)

2. Comprar preguntas de boletos

3. Problema del triángulo dividido

4. Problemas de coincidencia entre paréntesis

5. Problema de pila

6. Problema de multiplicación de matriz

Número Carterland y su recurrencia

f(0)=1;
f(1)=1;
f(2)=2;
f(3)=5;
f (4) = 14 = f (3) * f (0) + f (2) * f (1) + f (1) * f (2) + f (0 * f (3) // Recurns 1
f(5)=42
f(6)=132

Conoce a tu progresista:

2.Cn=(4*n-2)*C(n-1)/(n+1)

3.Cn=C(2*n,n)/(n+1)

4.Cn=C(2n,n)-C(2n,n-1)

Código Carterland

35 callands, usar largo

//Find the Cattleya number within 35
//Use long long 
void catlan()
{
	long long catlan_[36]={1,1,2};
	for(int i=3;i<36;i++)
	{
		catlan_[i]=0;
		for(int j=0;j<i;j++)
		{
			//According to the recursive grounding formula 
			catlan_[i]=catlan_[i]+catlan_[j]*catlan_[i-j-1];
		}
	}
}

35 o más procesamientos de Caterstown, con su propia

//Treatment of Cattleya numbers with more than 35 digits
//This code is below 100 
int a[101][101] ;	//a[i] represents the Cattleya number and needs to be output in reverse order
int b[101];			//The corresponding digit is the digit of Cattelan number
void catlan()
{
	//len is the number of digits, temp is a temporary variable 
	int len,carry,temp;
	a[0][0]=b[0]=1;
	a[1][0]=b[1]=1;
	
	len=1;	//Start from the first place, and then continue to rise, the number of digits may only remain the same or increase
	for(int i=0;i<101;i++)
	{
		//Multiplication processing
		for(int j=0;j<len;j++)
			a[i][j]=a[i-1][j]*(4*i-2);	//Process the multiplication part first
		carry=0;	//The carry here is carried out
		for(int j=0;j<len;j++)
		{
			temp=a[i][j]+carry;
			a[i][j]=temp%10;
			carry=temp/10;	
		}	
		//The highest bit carry processing 
		while(carry)	//carry is the total number that needs to be carried 
		{
			a[i][len]=carry%10;
			carry=carry/10;
			len++;	//Advance one digit, plus one digit 
		}
		
		//Division 
		carry=0;
		for(int j=len-1;j>=0;j--)
		{
			temp=carry*10+a[i][j];		//Divisor in analog division 
			a[i][j]=temp/(i+1);	//Each digit obtained by simulating division 
			carry=temp%(i+1);	//Simulate the remainder in division	
		} 
		
		//Eliminate the leading 0
		while(!a[i][len-1])
			len--;
		b[i]=len;	// Give the obtained digits to b[i] 
	}
	
}

.

  Base de datos Dameng integrada de Springboot (capa de persistencia diversificada)

Por Programación.Click

Más de 20 años programando en diferentes lenguajes de programación. Apasionado del code clean y el terminar lo que se empieza. ¿Programamos de verdad?

Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *