XidianOJ 1183 Water Problem: Items divided
题目描述
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的更多相关文章
- Items divided
Items divided 题目链接:http://acm.xidian.edu.cn/problem.php?id=1183 参考:http://www.cnblogs.com/wanghetao/ ...
- HDU 5832 A water problem(某水题)
p.MsoNormal { margin: 0pt; margin-bottom: .0001pt; text-align: justify; font-family: Calibri; font-s ...
- hdu5832 A water problem
A water problem Time Limit: 5000/2500 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)T ...
- hdu 5443 The Water Problem
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5443 The Water Problem Description In Land waterless, ...
- HDU 5867 Water problem (模拟)
Water problem 题目链接: http://acm.split.hdu.edu.cn/showproblem.php?pid=5867 Description If the numbers ...
- HDU 5832 A water problem
A water problem Time Limit: 5000/2500 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)T ...
- HDU 5832 A water problem (带坑水题)
A water problem 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5832 Description Two planets named H ...
- hdu 5443 The Water Problem 线段树
The Water Problem Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php? ...
- HDU-4974 A simple water problem
http://acm.hdu.edu.cn/showproblem.php?pid=4974 话说是签到题,我也不懂什么是签到题. A simple water problem Time Limit: ...
随机推荐
- Javascript DOM基础(一)概念
Dom基础概念: <!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" ...
- PL/SQL工具连接ORALCE数据库的方法
http://www.cnblogs.com/dongzhiquan/archive/2011/11/21/2257629.html 1.利用ORACLE NET MANAGER工具 1)打开 ORA ...
- Neo4j 两种索引Legacy Index与Schema Index区别
Legacy Indexes 在Neo4j 2.0版本之前,Legacy index被称作indexes.这个索引是通过外部图存储在外的Lucene实现,允许“节点”和“联系”以key:value键值 ...
- IE6 IE7 不支持 JSON
最近发现ie6.7不支持json,解决方法:引入json2.js <script type="text/javascript" src="json2.js& ...
- UrlRewrite伪静态
1.首先添加URLRewriter.dll.ActionlessForm.dll加到bin文件夹中,添加引用 注:URLRewriter.dll实现伪静态 ActionlessForm.dll是分页 ...
- CSS值得关注的那些事?
CSS值得关注的那些事? CSS层叠样式表的出现,使得样式表现层与HTML结构层分离,CSS样式与HTML结构层次清晰,一目了然.给我们前端开发者带来诸多的便利,然而,在实际前端开发中,还是有相当多的 ...
- 加速你的py.test, pytest-dist
URL: https://pypi.python.org/pypi/pytest-xdist 多线程跑测试 Command: py.test -d --tx 3*popen
- linux下压缩与解压(zip、unzip、tar)详解
linux下压缩与解压(zip.unzip.tar)详解 2012-05-09 13:58:39| 分类: linux | 标签:linux zip unzip tar linux命令详解 |举报|字 ...
- SQL Server使用convert对datetime日期数据进行获取
来源:http://database.51cto.com/art/201007/211883.htm 备注:本文的语法讲解确实是比较乱,似乎格式不太严谨.参考时还是以实例验证为准比较好 以下的文章主要 ...
- [Spring] - 动态设置properties
Spring的jar包用来做动态properties的getter/setter赋值方法: 1:需要的jar包: spring-beans-3.2.0.RC2.jar commons-logging- ...