题解 | #走方格的方案数#
走方格的方案数
https://www.nowcoder.com/practice/e2a22f0305eb4f2f9846e7d644dba09b
import java.util.*; public class Main { public static void main(String[] args) { Scanner fzhinput = new Scanner(System.in); int h = fzhinput.nextInt(); int l = fzhinput.nextInt(); System.out.println(fangfa(h+1, l+1)); } public static int fangfa(int h, int l) { int qp[][] = new int[h + 1][l + 1]; for (int i = 1; i <= h; i++) { qp[i][1] = 1; } for (int i = 1; i <= l; i++) { qp[1][i] = 1; } for (int i = 2; i <= h; i++) { for (int j = 2; j <= l; j++) { qp[i][j] = qp[i - 1][j] + qp[i][j - 1]; } } return qp[h][l]; } }