hdu 4045 Machine scheduling [ dp + 斯特林数]
Machine scheduling
Time Limit: 5000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1048 Accepted Submission(s): 387
Input will be four integers n,r,k,m.We assume that they are all between 1 and 1000.
Sample input means you can choose 1 and 4,1 and 5,2 and 5 in the same day.
And you can make the machines in the same group or in the different group.
So you got 6 schemes.
1 and 4 in same group,1 and 4 in different groups.
1 and 5 in same group,1 and 5 in different groups.
2 and 5 in same group,2 and 5 in different groups.
We assume 1 in a group and 4 in b group is the same as 1 in b group and 4 in a group.
13083183 | 2015-03-10 19:16:25 | Accepted | 4045 | 358MS | 25380K | 1461 B | G++ | czy |
#include <cstdio>
#include <cstring>
#include <stack>
#include <algorithm> #define ll long long
int const N = ;
ll const mod = ; using namespace std; ll stl[N][N];
ll sumstl;
ll n,r,k,m;
ll dp[N][N];
ll sum[N][N];
ll ans; void ini1()
{
memset(stl,,sizeof(stl));
ll i;
for(i=;i<=;i++){
stl[i][i]=;
}
stl[][]=;
ll p,j;
for(p=;p<=;p++){
for(j=;j<=p;j++){
stl[p][j]= (j*stl[p-][j]+stl[p-][j-])%mod;
}
} //for(p=1;p<=10;p++){
// for(j=1;j<=p;j++) printf(" p=%I64d j=%I64d stl=%I64d\n",p,j,stl[p][j]);
// }
} void ini()
{
ll i;
sumstl=;
for(i=;i<=m;i++){
sumstl=(sumstl+stl[r][i])%mod;
}
memset(dp,,sizeof(dp));
memset(sum,,sizeof(sum));
ans=;
// printf(" sumstl=%I64d\n",sumstl);
} void solve()
{
int i,j;
for(i=n;i>=;i--){
dp[i][]=;
sum[i][]=(sum[i+][]+dp[i][])%mod;
}
for(j=;j<=r;j++){
for(i=n-k;i>=;i--){
dp[i][j]=sum[i+k][j-];
sum[i][j]=(sum[i+][j]+dp[i][j])%mod;
}
}
ans=(sum[][r]*sumstl)%mod;
} void out()
{
printf("%I64d\n",ans);
} int main()
{
//freopen("data.in","r",stdin);
ini1();
while(scanf("%I64d%I64d%I64d%I64d",&n,&r,&k,&m)!=EOF)
{
ini();
solve();
out();
}
}
hdu 4045 Machine scheduling [ dp + 斯特林数]的更多相关文章
- HDU 4045 Machine scheduling (组合数学-斯特林数,组合数学-排列组合)
Machine scheduling Time Limit: 5000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Other ...
- HDU 4045 Machine scheduling --第二类Strling数
题意: n个数(1~n)取出r个数,取出的数相差要>=k, 然后分成m个可空组,问有多少种情况. 解法: 先看从n个数中取r个相差>=k的数的方法数,可以发现 dp[i][j] = dp[ ...
- bzoj 2159 Crash 的文明世界 && hdu 4625 JZPTREE ——第二类斯特林数+树形DP
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=2159 学习材料:https://blog.csdn.net/litble/article/d ...
- dp 斯特林数 HDU2512一卡通大冒险
这道题其实就是斯特林数,找不同的集合,一共有多少中组法,递推式就是dp[n][k] = dp[n - 1][k - 1] + k * dp[n - 1][k]; 这个式子可以这么解释,dp[n][k] ...
- hdu 2643 rank 第二类斯特林数
题意:给定n个人,要求这n个人的所有可能排名情况,可以多个人并列(这个是关键). 题解:由于存在并列的问题,那么对于n个人,我们最多有n个排名,枚举一下1~n,累加一下就好.(注意这里是变种的斯特林数 ...
- bzoj 2159 Crash 的文明世界 & hdu 4625 JZPTREE —— 第二类斯特林数+树形DP
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=2159 使用公式:\( n^{k} = \sum\limits_{i=0}^{k} S(k,i ...
- HDU 1176 免费馅饼 DP类似数塔题
解题报告: 小明走在一条小路上,这条小路的长度是10米,从左到右依次是0到10一共十个点,现在天上会掉馅饼,给出馅饼掉落的坐标和时间,一开始小明的位置是在坐标为5的位置, 他每秒钟只能移动一米的距离, ...
- [Luogu5320][BJOI2019]堪破神机(DP+斯特林数)
https://www.cnblogs.com/cjyyb/p/10747543.html 特征方程+斯特林反演化简式子,要注意在模998244353意义下5没有二次剩余,所以每个数都要用$a+b\s ...
- BZOJ2159 Crash的文明世界(树形dp+斯特林数)
根据组合意义,有nk=ΣC(n,i)*i!*S(k,i) (i=0~k),即将k个有标号球放进n个有标号盒子的方案数=在n个盒子中选i个将k个有标号球放入并且每个盒子至少有一个球. 回到本题,可以令f ...
随机推荐
- 微信小程序 逻辑层
1. 注册程序小程序APP在小程序的根目录下有一个app.js文件.有App(Object),App() 函数用来注册一个小程序.接受一个 Object 参数,其内便是小程序的生命周期.App() 必 ...
- Backbone.js之Todo源码浅析
相信每个接触了解过backbone的人都知道todo,网上的关于它的分析教程也都分析乱了.但是,知识只有自己学习领悟才是自己的,话不多说,正文开始. 在分析todo的源码之前,首先我们要知道todo具 ...
- JSP报错The value for the useBean class attribute *** is invalid.
环境:IDEA+Tomcat9+JDK1.8 在前期学习时,环境一直能够"正常"使用,实际上环境并没有完全搭建成功. 推荐: https://blog.csdn.net/lw_po ...
- ios 从相册视频中获取视频截图
//给image添加个分类 +(UIImage *)getImage:(NSURL: *)videoURL { AVURLAsset *asset = [[AVURLAsset alloc] init ...
- 原创 齐天大圣老司机亲传rescue恢复磁盘分区
老葵花哥哥课堂开课了本文档秉承爱看不看的原则 一不要钱 二服务大众的高尚情操咱们今天讲一讲rescue恢复磁盘分区 首先咱们搭建环境搞起来 (parted) mkpart #创建分区 Partitio ...
- Android(java)学习笔记174:服务(service)之混合方式开启服务
1. 前面我们已经讲过可以使用两种方式开启服务 startService----stopService: oncreate() ---> onstartCommand() ---& ...
- python struct.pack方法报错argument for 's' must be a bytes object 解决
参考 https://blog.csdn.net/weixin_38383877/article/details/81100192 在python3下使用struct模块代码 fileHead = s ...
- HTML5新特性之History
几年前,Ajax的兴起给互联网带来了新的生机,同时也使用户体验有了质的飞跃,用户无需刷新页面即可获取新的数据,而页面也以一种更具有交互性的形式为用户展现视图,可以说这种变化对互联网发展的贡献是史无前例 ...
- rfcn讲解博客
http://www.cnblogs.com/lillylin/p/6277094.html ROI pooling操作的输入(对于C+1个类)是k^2*(C+1)*W' *H'(W'和H'是ROI的 ...
- 2018美赛准备之路——Matlab基础——基本运算符号表示
π pi ln(x) log(x) lg(x) log10(x) log2(x) log2(x) 根号 sqrt(x) x的y次方 x^y e的y次方 exp(y)