题解 | #走方格的方案数#
走方格的方案数
http://www.nowcoder.com/practice/e2a22f0305eb4f2f9846e7d644dba09b
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
static int count = 0;
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String[] rcs = br.readLine().split(" ");
int[][] grid = new int[Integer.parseInt(rcs[0])+1][Integer.parseInt(rcs[1])+1];
go(grid,0,0);
System.out.println(count);
}
public static void go(int[][] rcs,int row,int col){
if (row == rcs.length-1 && col == rcs[row].length-1){
count++;
}else {
if (row == rcs.length-1){
go(rcs,row,col+1);
}else if (col == rcs[row].length-1){
go(rcs,row+1,col);
}else {
go(rcs,row+1,col);
go(rcs,row,col+1);
}
}
}
}