题目描述

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. PHP中常用的函数

    1.php 字符串截取函数 2.php取得当前时间函数 3.php 字符串长度函数 4.几种php 删除数组元素方法 5.php中var_dump()函数的详解说明 6.PHP preg_match正 ...

  2. KVC/KVO原理详解及编程指南

    一.简介 1.KVC简介 2.KVO简介 二.KVC相关技术 1.Key和Key Path 2.点语法和KVC 3.一对多关系(To-Many)中的集合访问器方法 4.键值验证(Key-Value V ...

  3. 常用加实用的Linux命令

    命令是计算机执行任务的指令.可以使用命令去关闭计算机,或者列出当前目录的文件列表,或当前文本的内容,或者屏幕显示一条消息等. 下面是各种基本的命令可供参考. 1.Ls - List ls会列举出当前工 ...

  4. jq 一些小方法

    js 控制a标签的onclick方法 document.getElementById("a3").onclick = ""; window.document.g ...

  5. Java笔记1-Java相关概念和如何实现跨平台

    一.Java相关概念 1.Java语言的核心特点跨平台面向对象 2.Java的历史版本JDK1.0,JDK1.1,JDK1.2....JDK5.0,JDK6.0,JDK7.0,JDK8.0 注意:JD ...

  6. HTTP请求 GET POST 网络编程实现(转)

    尊重原作者收集的资料,复制粘贴只为了避免作者文章出处哪天抽风了访问不了了导致资料消失. 原文地址 http://bbs.neworigin.net/forum.php?mod=viewthread&a ...

  7. JSBinding+SharpKit / 脚本加密(JSC或Bytecode,参考cocos2d-js)

    现在已经可以编译JSC,目前只能在 Windows 下编译 JSC.这个功能是从 cocos2d-js 抄过来的,他应该也支持在Mac编译,但是我没有试过. 菜单:JSB | Compile all ...

  8. libvirt

    http://libvirt.org/index.html libvirt supports: The KVM/QEMU Linux hypervisor The Xen hypervisor on ...

  9. sql server Datetime格式转换

    select CONVERT(varchar, getdate(), 120 ) 2004-09-12 11:06:08 select replace(replace(replace(CONVERT( ...

  10. Kafka/Metaq设计思想学习笔记 转

    转载自: http://my.oschina.net/geecoodeer/blog/194829 本文没有特意区分它们之间的区别,仅仅是列出其中笔者认为好的设计思想,供后续设计参考. 目前笔者并没有 ...