题解 | #走方格的方案数#
走方格的方案数
https://www.nowcoder.com/practice/e2a22f0305eb4f2f9846e7d644dba09b
import java.io.*; // 注意类名必须为 Main, 不要有任何 package xxx 信息 public class Main { public static void main(String[] args) throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String str; while((str = br.readLine()) != null){ String[] strs = str.split(" "); int m = Integer.parseInt(strs[0]); int n = Integer.parseInt(strs[1]); int[][] arr = new int[m+1][n+1]; for(int i = 0; i <=m;i++ ){ arr[i][0] = 1; } for(int j = 0; j<= n ;j++){ arr[0][j] = 1; } for(int i =1;i <= m;i++){ for(int j = 1;j <= n;j++){ arr[i][j] = arr[i-1][j] + arr[i][j-1]; } } System.out.println(arr[m][n]); } } }