//该函数表示m个苹果放在n个盘子的方案数
public static int putApple(int m, int n){
//三个迭代退出条件
if (n > m) return putApple(m, m);
if (n == 1) return 1;
if (m == 0) return 1;
//动态规划核心:f(m,n)=f(m,n-1)+f(m-n,n);
return putApple(m, n - 1) + putApple(m - n, n);
}
import java.util.*; public class Main{ public static void main(String[] args){ Scanner sc=new Scanner(System.in); while(sc.hasNext()){ int m=sc.nextInt(); int n=sc.nextInt(); System.out.println(apple(m,n)); } }
public static int apple(int m,int n){ if(m==0||n==1) return 1; if(n>m) return apple(m,m); else return apple(m,n-1)+apple(m-n,n); } }