Train stop (Cattleya number of issues)

Title Description

A n train carriages are numbered 1,2,3, ..., n. Each car has two motion, push and pop, the arrangement may ask carriages out of the stack of n number of species.
Enter
a number, n (n <= 60000)
outputs
a number n s denotes a carriage arrangement stack may
sample the input
3
Sample output
5
a typical example of the number of Cattleya, but use the prime factorization of factorial (basic arithmetic Theorem) to count, or will T

Here Insert Picture Description The vertical factorial prime factorisation, then take off after about the same quality factor, and finally in addition to n + 1
Here Insert Picture Description

Reference Code:

#include <iostream>
#include <algorithm>
using namespace std;
const int maxn = 2e5 + 10;
int f[maxn];
int main()
{
	int n;
	cin >> n;
	f[0] = f[1] = 1;
	for (int i = 2; i <= n; i++)
		for (int j = 0; j < i; j++)
			f[i] += f[j] * f[i - j - 1];
	cout << f[n];
	return 0;
}
Published 77 original articles · won praise 19 · views 10000 +

Guess you like

Origin blog.csdn.net/qq_43488547/article/details/101521041