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 ...
随机推荐
- spring security自定义拒绝访问页面
如果试图访问一个没有访问权限的页面,那么页面会出现403 访问错误. 如果我们希望自定义访问拒绝页面,只需要随便创建一个jsp页面,让后将这个页面的位置放到配置文件中. 下面创建一个accessDen ...
- 最轻量级的前端Mvc框架backbone
最轻量级的前端Mvc框架backbone依赖最轻量级的库understore backbone并非将前端再次切分为mvc,而是分为了七大模块,分别是:Events.Model.Collection.R ...
- original.txt和提交的页面输出的文字的混合文件
如果从准确的角度来说,那PHP文档是最准确的,因为它很简练的列出了实现文本类文件触发下载所需要的三条语句,以PDF为例就是: 代码如下:// We'll be outputting a PDF hea ...
- MySQL执行存储过程权限
http://url.cn/f2bj78 MySQL grant不能在on后面写多个对象
- php课程---建立一个简单的下拉列表框
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- SSH相关
[root@www ~]# vim /etc/ssh/sshd_config# 1. 关于SSH Server 的整体设定,包含使用的port 啦,以及使用的密码演算方式# Port 22# SSH ...
- C++ Primer Pluse_7_课后题
#include <iostream> using namespace std; double Sum2(double x, double y) { double sum = 0; if ...
- 《Linux内核设计与实现》CHAPTER4阅读梳理
<Linux内核设计与实现>CHAPTER4阅读梳理 [学习时间:3hours] [学习内容:多任务:进程调度策略:Linux中进程调度的关键问题:抢占] 个人思考部分见[]标出的部分 一 ...
- RDIFramework.NET 框架之组织机构权限设置
RDIFramework.NET 框架之组织机构权限设置 对于某些大型的企业.信息系统,涉及的组织机构较多,模块多.操作权限也多,对用户或角色一一设置模块.操作权限等比较繁琐.我们可以直接对某一组织机 ...
- Linux下使用shell实现上传linux下某个目录下所有文件到ftp
首先我们需要搞清楚单个文件怎么上传,把这个单文件上传到ftp上的实现命名为一个:upload_to_ftp_command.sh 之后,需要弄清楚怎么实现遍历一个目录下的所有文件的,把这个遍历某个目录 ...