题目描述

Youyouyouyou is very interested in math, one day, an idea came into his mind that how many ways he can patition n same things into no more than m groups? he think it too hard for him, so youyouyouyou ask wise cyt for help, but wise cyt don’t want to talk with youyouyouyou because it is too easy for him, now can you help youyouyouyou solve this problem?

输入

multi test cases, two integers n and m(1<=m<=n<=1000) , end with n = m = 0.

输出

output

#include <cstdio>
#include <algorithm>
#include <iostream>
using namespace std;
#define MOD 1000000007
typedef long long LL;
LL f[][] = {},ans[][] = {};
int main(){
int n,m,i,j;
for (i=;i<=;i++){
f[i][] = ;
f[i][] = ;
f[i][i] = ;
f[][i] = ;
}
for (i=;i<=;i++){
for (j=;j<=i;j++){
if (i == j) f[i][j] = ;
else
f[i][j] = (f[i-][j-] + f[i-j][j]) % MOD;
}
}
for (i=;i<=;i++){
ans[i][] = f[i][];
for (j=;j<=i;j++){
ans[i][j] = (ans[i][j-] + f[i][j]) % MOD;
}
}
while (scanf("%d %d",&n,&m) != EOF){
if (n == && m == ) break;
// LL res = 0;
// for (i=1;i<=m;i++){
// res = (res + f[n][i]) % MOD;
// }
// printf("%lld\n",res);
printf("%lld\n",ans[n][m]);
}
return ;
}

an answer modulo 1e9 + 7 per line

--正文

n个相同的球放入m个相同的盒子,允许有空盒

F(n,m) = F(n-1,m-1) + F(n-m,m)

注意边界的处理

XidianOJ 1183 Water Problem: Items divided的更多相关文章

  1. Items divided

    Items divided 题目链接:http://acm.xidian.edu.cn/problem.php?id=1183 参考:http://www.cnblogs.com/wanghetao/ ...

  2. HDU 5832 A water problem(某水题)

    p.MsoNormal { margin: 0pt; margin-bottom: .0001pt; text-align: justify; font-family: Calibri; font-s ...

  3. hdu5832 A water problem

    A water problem Time Limit: 5000/2500 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)T ...

  4. hdu 5443 The Water Problem

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5443 The Water Problem Description In Land waterless, ...

  5. HDU 5867 Water problem (模拟)

    Water problem 题目链接: http://acm.split.hdu.edu.cn/showproblem.php?pid=5867 Description If the numbers ...

  6. HDU 5832 A water problem

    A water problem Time Limit: 5000/2500 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)T ...

  7. HDU 5832 A water problem (带坑水题)

    A water problem 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5832 Description Two planets named H ...

  8. hdu 5443 The Water Problem 线段树

    The Water Problem Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php? ...

  9. HDU-4974 A simple water problem

    http://acm.hdu.edu.cn/showproblem.php?pid=4974 话说是签到题,我也不懂什么是签到题. A simple water problem Time Limit: ...

随机推荐

  1. RSS(Residual Sum of Squares)的自由度为什么是n-1呢

    [转载请注明出处]http://www.cnblogs.com/mashiqi 在回归问题中,偶尔我们会遇到求方差的估计的情况.举了例子,我们常常通过Gaussian分布${\cal N}(\mu , ...

  2. php部分---注册审核

    用户界面: 1.登录界面,用户填写相关信息 <form action="dengluchuli.php" method="post"> <di ...

  3. java SpringUtil获取bean

    package com.whaty.framework.common.spring; import java.io.PrintStream; import org.springframework.be ...

  4. unity, 播放循环背景音乐注意事项

    循环背景音乐用wav格式,不要用mp3. 参考:http://answers.unity3d.com/questions/343057/how-do-i-make-unity-seamlessly-l ...

  5. 接口自动化之Postman+Newman

    简介 Postman 使一款可以方便我们调用API的工具,通过Postman 与 Newman结合我们还可以批量运行API达到API自动化测试的目的. Postman 安装 Window 系统需要先安 ...

  6. [solr] - suggestion

    前文使用了SpellCheck做了个自动完成模拟(Solr SpellCheck),使用第一种SpellCheck方式做auto-complete,是基于动态代码方式建立内容,下面方式可通过读文件方式 ...

  7. 从jsTree演示代码中提取的在线文件查看

    从jsTree演示代码中提取的在线文件查看 jsTree 请参考:https://www.jstree.com/ 效果如下: 代码下载:http://files.cnblogs.com/files/z ...

  8. Android AChartEngine 个性化设置

    AChartEngine的确是一个强大的图标引擎,但文档写得不是很详细,很多设置只能通过方法名推测和实际尝试,下面是一些自己在实际中遇到的需要设置的选项,常见的那些和通过方法名就能轻松猜到的就不赘述了 ...

  9. Java多线程--wait和join

    首先从公司一道笔试题开始 package test; public class Test implements Runnable { public int i = 0; @Override publi ...

  10. C++11:POD数据类型

    版权声明:本文为博主原创文章,未经博主允许不得转载. 目录(?)[+] 啥是POD类型? POD全称Plain Old Data.通俗的讲,一个类或结构体通过二进制拷贝后还能保持其数据不变,那么它就是 ...