描述 |
|
---|---|
知识点 | 字符串,循环,函数,指针,枚举,位运算,结构体,联合体,文件操作,递归 |
运行时间限制 | 10M |
内存限制 | 128 |
输入 | 输入两个正整数
|
输出 | 返回结果 |
样例输入 | 2 2 |
样例输出 | 6 |
path[i][j] = path[i - 1][j] + path[i][j - 1];
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
while (scanner.hasNext()) {
int n = scanner.nextInt();
int m = scanner.nextInt();
System.out.println(count(n, m));
}
scanner.close();
}
private static int count(int n, int m) {
int[][] path = new int[n + 1][m + 1];
for (int i = 0; i < path[0].length; i++) {
path[0][i] = 1;
}
for (int i = 0; i < path.length; i++) {
path[i][0] = 1;
}
for (int i = 1; i < path.length; i++) {
for (int j = 1; j < path[0].length; j++) {
path[i][j] = path[i - 1][j] + path[i][j - 1];
}
}
return path[n][m];
}
}