HDU Machine scheduling
Machine scheduling
Time Limit : 5000/2000ms (Java/Other) Memory Limit : 32768/32768K (Java/Other)
Total Submission(s) : 4 Accepted Submission(s) : 1
Font: Times New Roman | Verdana | Georgia
Font Size: ← →
Problem Description
Input
Input will be four integers n,r,k,m.We
assume that they are all between 1 and 1000.
Output
Sample Input
5 2 3 2
Sample Output
6
Hint
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.
Source
有N个机器,每天选出R个机器,而且每两个机器的编号差要大于等于K,而且每天将R
个机器最多分为M组工作,问最多有多少种方案。
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<cstdlib>
using namespace std;
typedef __int64 LL; LL p = ;
LL dp[][];
LL f[][]; void init()
{
for(int i=;i<=;i++){
for(int j=;j<=i;j++){
if(j==)dp[i][j]=;
else if(j==i)dp[i][j]=;
else dp[i][j] = (j*dp[i-][j]+dp[i-][j-])%p;
}
}
for(int i=;i<=;i++)
for(int j=;j<=i;j++)
dp[i][j] = (dp[i][j]+dp[i][j-])%p;
}
int main()
{
int n,r,k,m;
init();
while(scanf("%d%d%d%d",&n,&r,&k,&m)>)
{ /** f[i][j] i个数字 最大为j 有多少种方法 **/ for(int i=;i<=;i++)for(int j=;j<=;j++) f[i][j]=;
int kk = n-k;
for(int i=;i<=n;i++)f[][i]=; for(int i=;i<=r;i++)
{
LL hxl = ;
for(int j=;j<=kk;j++){
hxl = (hxl+f[i][j])%p;
f[i+][j+k]=hxl;
}
}
LL sum = ;
for(int i=;i<=n;i++) sum =(sum+f[r][i])%p;
printf("%I64d\n",(sum*dp[r][min(r,m)])%p);
}
return ;
}
HDU Machine scheduling的更多相关文章
- HDU 4045 Machine scheduling (组合数学-斯特林数,组合数学-排列组合)
Machine scheduling Time Limit: 5000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Other ...
- hdu 4045 Machine scheduling [ dp + 斯特林数]
传送门 Machine scheduling Time Limit: 5000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/O ...
- HDU4045 Machine scheduling —— 隔板法 + 第二类斯特林数
题目链接:https://vjudge.net/problem/HDU-4045 Machine scheduling Time Limit: 5000/2000 MS (Java/Others) ...
- HDU 4045 Machine scheduling --第二类Strling数
题意: n个数(1~n)取出r个数,取出的数相差要>=k, 然后分成m个可空组,问有多少种情况. 解法: 先看从n个数中取r个相差>=k的数的方法数,可以发现 dp[i][j] = dp[ ...
- 【hdu4045】Machine scheduling(dp+第二类斯特林数)
传送门 题意: 从\(n\)个人中选\(r\)个出来,但每两个人的标号不能少于\(k\). 再将\(r\)个人分为不超过\(m\)个集合. 问有多少种方案. 思路: 直接\(dp\)预处理出从\(n\ ...
- hdu 1150 Machine Schedule 最少点覆盖转化为最大匹配
Machine Schedule Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php? ...
- hdu 1150 Machine Schedule 最少点覆盖
Machine Schedule Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php? ...
- hdu 1150 Machine Schedule(二分匹配,简单匈牙利算法)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1150 Machine Schedule Time Limit: 2000/1000 MS (Java/ ...
- HDU——T 1150 Machine Schedule
http://acm.hdu.edu.cn/showproblem.php?pid=1150 Time Limit: 2000/1000 MS (Java/Others) Memory Limi ...
随机推荐
- DateUtils
package com.vcredit.ddcash.batch.util; import java.text.SimpleDateFormat;import java.util.Calendar;i ...
- Python的全局变量
应该尽量避免使用全局变量.不同的模块都可以自由的访问全局变量,可能会导致全局变量的不可预知性.对全局变量,如果程序员甲修改了_a的值,程序员乙同时也要使用_a,这时可能导致程序中的错误.这种错误是很难 ...
- shader三种变量类型(uniform,attribute和varying)
uniform变量在vertex和fragment两者之间声明方式完全一样,则它可以在vertex和fragment共享使用.(相当于一个被vertex和fragment shader共享的全局变量) ...
- hover事件优化(延时操作)
JQ的hover事件拓展 编写原因:当鼠标滑过某个带有hover事件的元素,但是仅仅是路过,并不是希望查看此部分内容的时候,效果不理想 $.fn.extend({ delayed : function ...
- 基于 ThinkPHP 3.2.3 的页面静态化功能的实现
PHP 的页面静态化有多种实现方式,比如使用输出缓冲(output buffering),该种方式是把数据缓存在 PHP 的缓冲区(内存)中,下一次取数据时直接从缓冲区中读取数据,从而避免了脚本的编译 ...
- js基础细节
js细节 1.所有的全局变量都是window的属性. 语句 var a=1; 等价于 window.a=1; 用 "变量名称" in window 来验证全局变量是否声明. 2.所 ...
- angularjs backbone 集成requirejs 模块化
首先认识requirejs requirejs是个包加载器,核心功能是模块化管理,可以实现按需加载. 重点是明白 模块化不是按需加载. 模块化的意义: 是通过代码逻辑表明模块之间的依赖关系和执行顺序, ...
- Fixing “WARNING: UNPROTECTED PRIVATE KEY FILE!” on Linux
If you are getting this error then you probably reset the permissions on your hidden .ssh directory ...
- LeetCode Reconstruct Itinerary
原题链接在这里:https://leetcode.com/problems/reconstruct-itinerary/ 题目: Given a list of airline tickets rep ...
- role roleMapping 权限说明
根据我的理解,希望能帮助到大家 role表 是权限列表. roleMapping 关联权限(例如那个用户在那个权限里面,或者权限里面包含那个权限) roleMapping的数据不能单独添加.必须在ro ...