编程介的小学生 2017-02-13 03:03 采纳率: 20.5%
浏览 740
已采纳

Cake Pieces and Plates

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

  • 写回答

2条回答 默认 最新

  • devmiao 2017-02-13 18:23
    关注

    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));
        }
    }
    

    }

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码