题目描述

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. Unity Sprite转Prefab

    新项目使用Unity5.X,遇到了一些问题,其中就有Sprite的管理更新问题,查了一些资料,Mono推荐的是转为Prefab处理. 看了一些国外同行的处理方法,分析了一个编辑器插件脚本.学到了一些技 ...

  2. Mac下到Linux主机ssh免密码登录

    最近忙得忘乎所以,写篇博客放松放松,RT,直接上命令好了 # Local ssh-keygen -t rsa scp ~/.ssh/id_rsa.pub username@server:~/.ssh/ ...

  3. 在线聊天室的实现(2)--基于Netty 4.x的Echo服务器实现

    前言: 就如前文所讲述的, 聊天室往往是最基本的网络编程的学习案例. 本文以WebSocket为底层协议, 实现一个简单的基于web客户端的Echo服务. 服务器采用Netty 4.x来实现, 源于其 ...

  4. LintCode Validate Binary Search Tree

    Validate Binary Search Tree Given a binary tree, determine if it is a valid binary search tree (BST) ...

  5. ES6 - for...of

    for...of是一种用来遍历数据结构的方法,可遍历的对象包括:数组,对象,字符串,节点数组等 我们先来看一下现在存在的遍历方式: var arr=[1,2,3,4] (1)for循环 缺点:代码不够 ...

  6. yii框架便利类CVarDumper使用

    1.类文件位置:path/to/yiiframework/utils/CVarDumper.php 2.作用:CVarDumper is intended to replace the buggy P ...

  7. ✡ leetcode 163. Missing Ranges 找出缺失范围 --------- java

    Given a sorted integer array where the range of elements are in the inclusive range [lower, upper], ...

  8. h4和h5的区别

    h4和h5的区别 相关文章 微信ID:WEB_wysj(点击关注)◎◎◎◎◎◎◎◎◎一┳═┻[▄ (页底留言开放,欢迎来吐槽) ●●● 1.HTML5为什么只需要写<!DOCTYPEHTML&g ...

  9. python 之post、get与cookie实战

    项目名称:登陆考勤管理系统爬取个人考勤信息并写入excel表格 编写目的: 公司经常要统计员工的考勤信息,而员工每次都要登陆考勤系统,再复制相关信息出来,贴到EXCEL,再转给统计人员,统计人员再挨个 ...

  10. CentOS6.8 MySQL 5.6实现主从复制

    主库操作 1.将mysqldump命令添加到/usr/bin中 ln -s /application/mysql/bin/mysqldump /usr/bin/ 2.开启master上的log-bin ...