Skip to content

Commit

Permalink
Update catalan.md
Browse files Browse the repository at this point in the history
修复例题格式,代码格式,删除了重复的公式
  • Loading branch information
hsfzLZH1 authored Oct 5, 2019
1 parent 9549354 commit f1c2372
Showing 1 changed file with 19 additions and 21 deletions.
40 changes: 19 additions & 21 deletions docs/math/catalan.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,32 +44,30 @@ $$
H_n = \binom{2n}{n} - \binom{2n}{n-1}
$$

f[n] = f[0] * f[n - 1] + f[1] * f[n - 2] + ... + f[n - 1] * f[0]

具体实例[https://www.luogu.org/problem/P1044](洛谷 P1044 栈)

#include <iostream>

using namespace std;

int n;
long long f[25];

int main(){
f[0] = 1;
cin >> n;
for(int i = 1; i <= n; i++)
f[i] = f[i - 1] * (4 * i - 2) / (i + 1);
//这里用的是常见公式2
cout << f[n] << endl;
return 0;
}
??? note " 例题[洛谷 P1044 栈](https://www.luogu.org/problem/P1044)"
题目大意:入栈顺序为 $1,2,\ldots ,n$ ,求所有可能的出栈顺序的总数。

```cpp
#include <iostream>
using namespace std;
int n;
long long f[25];
int main(){
f[0] = 1;
cin >> n;
for(int i = 1; i <= n; i++)
f[i] = f[i - 1] * (4 * i - 2) / (i + 1);
//这里用的是常见公式2
cout << f[n] << endl;
return 0;
}
```

## 路径计数问题

非降路径是指只能向上或向右走的路径。

1. 从 $(0,0)$ 到 $(m,n)$ 的非降路径数等于 mxny 的排列数,即 ${n + m \choose m}$ 。
1. 从 $(0,0)$ 到 $(m,n)$ 的非降路径数等于 $m$$x$$n$$y$ 的排列数,即 ${n + m \choose m}$ 。

2. 从 $(0,0)$ 到 $(n,n)$ 的除端点外不接触直线 $y=x$ 的非降路径数:

Expand Down

0 comments on commit f1c2372

Please sign in to comment.