题解 | #走方格的方案数#
走方格的方案数
http://www.nowcoder.com/practice/e2a22f0305eb4f2f9846e7d644dba09b
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
String nm = scan.nextLine();
int n = Integer.valueOf(nm.split(" ")[0].trim()) + 1;
int m = Integer.valueOf(nm.split(" ")[1].trim()) + 1;
int[][] dp = new int[n][m];
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
if (0 == i || 0 == j) {
dp[i][j] = 1;
continue;
}
dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
}
}
System.out.println(dp[n - 1][m - 1]);
}
}