题目来源
分析
结论
代码
import java.util.Scanner;public class Main {public static int dg(int n, int m) {if (n == 1 || m == 1) {return (m + n);} else {return dg(n - 1, m) + dg(n, m - 1);}}public static void main(String[] args) {Scanner sc = new Scanner(System.in);int n = sc.nextInt();int m = sc.nextInt();// if (n == 1 && m == 1) {// System.out.println(m + n);// } else if (n == 1 && (m >= 1)) {// System.out.println(m + n);// } else if (m == 1 && (n >= 1)) {// System.out.println(m + n);// } else {// System.out.println(dg(n, m));// }System.out.println(dg(n, m));sc.close();}
}