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

A Baidu’s engineer needs to analyze and process large amount of data on machines every day. The machines are labeled from 1 to n. On each day, the engineer chooses r machines to process data. He allocates the r machines to no more than m groups ,and if the difference of 2 machines' labels are less than k,they can not work in the same day. Otherwise the two machines will not work properly. That is to say, the machines labeled with 1 and k+1 can work in the same day while those labeled with 1 and k should not work in the same day. Due to some unknown reasons, the engineer should not choose the allocation scheme the same as that on some previous day. otherwise all the machines need to be initialized again. As you know, the initialization will take a long time and a lot of efforts. Can you tell the engineer the maximum days that he can use these machines continuously without re-initialization.

Input

Input end with EOF.
Input will be four integers n,r,k,m.We
assume that they are all between 1 and 1000.

Output

Output the maxmium days modulo 1000000007.

Sample Input

5 2 3 2

Sample Output

6

Hint

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.

Source

The 36th ACM/ICPC Asia Regional Beijing Site —— Online Contest  
 

有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的更多相关文章

  1. HDU 4045 Machine scheduling (组合数学-斯特林数,组合数学-排列组合)

    Machine scheduling Time Limit: 5000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Other ...

  2. hdu 4045 Machine scheduling [ dp + 斯特林数]

    传送门 Machine scheduling Time Limit: 5000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/O ...

  3. HDU4045 Machine scheduling —— 隔板法 + 第二类斯特林数

    题目链接:https://vjudge.net/problem/HDU-4045 Machine scheduling Time Limit: 5000/2000 MS (Java/Others)   ...

  4. HDU 4045 Machine scheduling --第二类Strling数

    题意: n个数(1~n)取出r个数,取出的数相差要>=k, 然后分成m个可空组,问有多少种情况. 解法: 先看从n个数中取r个相差>=k的数的方法数,可以发现 dp[i][j] = dp[ ...

  5. 【hdu4045】Machine scheduling(dp+第二类斯特林数)

    传送门 题意: 从\(n\)个人中选\(r\)个出来,但每两个人的标号不能少于\(k\). 再将\(r\)个人分为不超过\(m\)个集合. 问有多少种方案. 思路: 直接\(dp\)预处理出从\(n\ ...

  6. hdu 1150 Machine Schedule 最少点覆盖转化为最大匹配

    Machine Schedule Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php? ...

  7. hdu 1150 Machine Schedule 最少点覆盖

    Machine Schedule Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php? ...

  8. hdu 1150 Machine Schedule(二分匹配,简单匈牙利算法)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1150 Machine Schedule Time Limit: 2000/1000 MS (Java/ ...

  9. HDU——T 1150 Machine Schedule

    http://acm.hdu.edu.cn/showproblem.php?pid=1150 Time Limit: 2000/1000 MS (Java/Others)    Memory Limi ...

随机推荐

  1. js的extend和fn.extend使用

    $.fn.extend扩展的是一个jQuery对象函数,$.extend扩展的是一个jQuery全局函数 <!DOCTYPE html> <html> <head> ...

  2. Cocos2dx淌坑日记:粒子系统PositionType的正确使用

    Cocos2dx中的粒子系统,有三种定位方式,对应于不同需求. 之前我有一个想做的效果,是类似彗星的扫尾.但是当父节点也就是CCLayer跟着物体移动的时候,发现尾巴并没有跟随CCLayer移动,而是 ...

  3. JMeter之JDBC接口测试

    使用jmeter连接数据库后,即可在jmeter中构造对数据库进行增删改查的请求以对数据库进行测试,以下以mysql数据库为例,演示jmeter连接mysql并进程查询操作的步骤. 1.确保mysql ...

  4. yield return的用法简介

    使用yield return 语句可一次返回一个元素. 迭代器的声明必须满足以下要求: 返回类型必须为 IEnumerable.IEnumerable<T>.IEnumerator 或 I ...

  5. IIS应用程序池最大进程数设置

    1.当工作进程数>1时,如果有多个连接请求就会启动多个工作进程实例来处理,所启动的最多工作进程数就是你设置的最大进程数,后续更多的连接请求会循环的发送至不同的工作进程来处理.每个工作进程都能承担 ...

  6. C# 消息队列

    阅读目录 1. 消息队列是什么? 2. 常见的消息队列框架有哪些? 3. MSMQ介绍 4. RabbitMQ介绍 消息队列是什么 简单的理解就是将消息添加一个队列中,使用时在从这个队列中取出来.那么 ...

  7. Selenium脚本编写环境的搭建/XPath

    编写环境主要分为三个部分: JUnit : java单元测试框架: Firebug: firefox 附加组件,Firebug是firefox下的一个扩展,能够调试所有网站语言,如Html,Css等, ...

  8. 转: KindEditor 图片空间文件增加删除文件、文件夹功能(ASP语言环境)

    KindEditor 图片上传功能中集成的图片空间文件管理插件可以对已上传图片进行管理,十分便捷,只是没有图片删除功能,仔细研读xieliang分享的经验后,自己动手改造了一下,顺便分享给有同样需求的 ...

  9. WP8.1 windows phone 8.1 二次退出

    public MainPage() { HardwareButtons.BackPressed += HardwareButtons_BackPressed; //注册后退键 } private vo ...

  10. iOS,视图控制器相关(UIViewController)

    1.视图控制器各个方法调用时机 2.选项卡(Tab Bar)和导航栏(Navigation Bar) 3.有无控制器的页面跳转 4.页面跳转隐藏底部选项卡 5.获取导航栏和状态栏高度,隐藏导航栏返回按 ...