You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
457 B

#include <iostream>
using namespace std;
int m, n;
const int N = 110;
int a[N][N];
//动态规划 DP
int main() {
cin >> m >> n;
//初始化
for (int i = 1; i <= n; i++) a[1][i] = 1;
for (int i = 1; i <= m; i++) a[i][1] = 1;
//找规律,两者和
for (int i = 2; i <= m; i++)
for (int j = 2; j <= n; j++)
a[i][j] = a[i][j - 1] + a[i - 1][j];
printf("%d", a[m][n]);
return 0;
}