网格走法数目
网格走法数目
http://www.nowcoder.com/questionTerminal/e27b9fc9c0ec4a17a5064fb6f5ab13e4
import java.util.*;
public class Main{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int x = sc.nextInt(), y = sc.nextInt();
System.out.println(f(x, y));
}
static int f(int x, int y){
if(x == 0 || y == 0) return 1; //撞墙之后,就只剩一条路倒着走了
return f(x - 1, y) + f(x, y - 1);//从右下角往回倒着走
}
}