Description
kcm1700, ntopia, suby, classic, tkwons, and their friends are having a birthday party for kcm1700. Of course, there is a very large birthday cake. They divide the birthday cake into undistinguishable pieces and put them on identical plates. kcm1700 is curious, so he wants to know how many ways there are to put m cake pieces on n plates.
Input
In the only input line, there are two integers n, m (1 ≤ n, m ≤ 4 500), which are the number of the plates and the number of the cake pieces respectively.
Output
If the number of ways is K, just output K mod 1000000007 because K can be very large.
Sample Input
3 7
Sample Output
8
import java.util.Scanner;
public class hdu1028整数划分 {
static long[][]a=new long[122][122];
private static long fun(int n,int m) {
if(a[n][m]!=0)return a[n][m];
if(n<1||m<1)return 0;
if(n==1||m==1)return 1;
if(n<m) return a[n][m]=fun(n,n);
if(n==m) return a[n][m]=1+fun(n,n-1);
return a[n][m]=fun(n,m-1)+fun(n-m,m);
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while(sc.hasNext()){
int n = sc.nextInt();
System.out.println(fun(n,n));
}
}
}
http://blog.csdn.net/chao1983210400/article/details/16983303