import java.util.Scanner;
/**
* Created by Administrator on 2016/9/10.
* 题目:
* 有一个X*Y的网格,小团要在此网格上从左下角到右下角,只能走格点且只能向右或向下,请设计一个算法,计算小团有
* 多少种走法,给定两个正整数int x,int y,请返回小团的走法数目。
* 输入包括一行,逗号隔开的两个正整数x和y,取值范围[1,10]
* 输出包括一行,为走法的数目
*
* 思路:
* 0 1 1 1 1
* 1 2 3 4 5
* 1 3 6 10 15
* 1 4 10 20 35
* 1 5 15 35 70
* 每个数代表走到此处的走法,是它上方和左边的两个数之和。
* 第一行和第一列都为1
*/
public class AllPath {
public static void main(String[] args){
Scanner scanner = new Scanner(System.in);
while(scanner.hasNext()){
String str = scanner.nextLine();
int x = Integer.parseInt(str.split(",")[0]);//读取x行
int y = Integer.parseInt(str.split(",")[1]);//读取y列
int[][] arr = new int[x][y];
arr[0][0] = 0;
for(int i=1;i<x;i++){
for(int j=1;j<y;j++){
arr[i][0] = 1;
arr[0][j] = 1;
arr[i][j] = arr[i][j-1]+arr[i-1][j];
}
}
System.out.println(arr[x-1][y-1]);
}
}
}
/**
* Created by Administrator on 2016/9/10.
* 题目:
* 有一个X*Y的网格,小团要在此网格上从左下角到右下角,只能走格点且只能向右或向下,请设计一个算法,计算小团有
* 多少种走法,给定两个正整数int x,int y,请返回小团的走法数目。
* 输入包括一行,逗号隔开的两个正整数x和y,取值范围[1,10]
* 输出包括一行,为走法的数目
*
* 思路:
* 0 1 1 1 1
* 1 2 3 4 5
* 1 3 6 10 15
* 1 4 10 20 35
* 1 5 15 35 70
* 每个数代表走到此处的走法,是它上方和左边的两个数之和。
* 第一行和第一列都为1
*/
public class AllPath {
public static void main(String[] args){
Scanner scanner = new Scanner(System.in);
while(scanner.hasNext()){
String str = scanner.nextLine();
int x = Integer.parseInt(str.split(",")[0]);//读取x行
int y = Integer.parseInt(str.split(",")[1]);//读取y列
int[][] arr = new int[x][y];
arr[0][0] = 0;
for(int i=1;i<x;i++){
for(int j=1;j<y;j++){
arr[i][0] = 1;
arr[0][j] = 1;
arr[i][j] = arr[i][j-1]+arr[i-1][j];
}
}
System.out.println(arr[x-1][y-1]);
}
}
}