题目传送门
1 /*
2 模拟递推水题
3 */
4 #include <cstdio>
5 #include <iostream>
6 #include <cmath>
7 #include <algorithm>
8 #include <cstring>
9 #include <string>
10 #include <map>
11 using namespace std;
12
13 const int MAXN = 10 + 10;
14 const int INF = 0x3f3f3f3f;
15 int a[MAXN][MAXN];
16
17 int main(void)
18 {
19 #ifndef ONLINE_JUDGE
20 freopen ("A.in", "r", stdin);
21 #endif
22
23 int n;
24 while (~scanf ("%d", &n))
25 {
26 for (int i=1; i<=n; ++i)
27 {
28 a[1][i] = 1;
29 a[i][1] = 1;
30 }
31
32 for (int i=2; i<=n; ++i)
33 {
34 for (int j=2; j<=n; ++j)
35 {
36 a[i][j] = a[i-1][j] + a[i][j-1];
37 }
38 }
39
40 printf ("%d
", a[n][n]);
41 }
42
43 return 0;
44 }