hdu 4045 Machine scheduling 斯特林数+插板法
来源:互联网 发布:linux系统怎么用java 编辑:程序博客网 时间:2024/04/28 02:50
Machine scheduling
Time Limit: 5000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1069 Accepted Submission(s): 400
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.
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
6HintSample 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.
传送门:http://blog.csdn.net/acm_cxlove/article/details/7857785
代码:
#include <stdio.h>#define MOD 1000000007int c[2010][2001] = {1} , stir[1010][1010] = {1} ;int min(int a , int b){return a>b?b:a ;}int main(){for(int i = 0 ; i <= 2000 ; ++i){c[i][0] = c[i][i] = 1 ;for(int j = 1 ; j < i ; ++j){c[i][j] = (c[i-1][j-1]+c[i-1][j])%MOD ;}}for(int i = 1 ; i <= 1000 ; ++i){stir[i][0] = 0 ;stir[i][i] = 1 ;for(int j = 1 ; j < i ; ++j){stir[i][j] = ((long long)j*stir[i-1][j]+stir[i-1][j-1])%MOD ;}}int n,r,k,m ;while(~scanf("%d%d%d%d",&n,&r,&k,&m)){int rem = n-(r-1)*k-1 ;if(rem<0){puts("0") ;}else{long long sum = 0 ;int len = min(r,m) ;for(int i = 1 ; i <= len ; ++i){sum = (sum+stir[r][i])%MOD ;}printf("%d\n",c[rem+r][r]*sum%MOD) ;}}return 0 ;}
与君共勉
0 0
- hdu 4045 Machine scheduling 斯特林数+插板法
- hdu-4045-Machine scheduling-组合数学(插板+第二类Stirling数)
- hdu 4045 Machine scheduling
- hdu-4045 Machine scheduling
- Hdu 4045 Machine scheduling (组合数,斯特林数)
- [Stirling] HDU 4045 Machine scheduling
- hdu 4045 Machine scheduling 组合数学
- hdu 4045 Machine scheduling(组合数学)
- Machine scheduling HDU
- hdoj-4045-Machine scheduling
- HDU 4045 Machine scheduling(11年北京网赛,组合数,斯特林数)
- HDU 4045 Machine scheduling (组合数学-斯特林数,组合数学-排列组合)
- HDU 4045 Machine scheduling --第二类Strling数
- hdu 3037 插板法组合 + lucas定理
- HDU/HDOJ 4045 BUPT 216 Machine scheduling 2011ACM北京网络赛 F题
- HDU_4045 Machine scheduling 数学
- 插板法分小球
- 插板法的应用
- 读《数据结构学习指导和习题解答》(C++语言版)有感
- Android数据的四种存储方式(2)SQLite
- Shell基础-Bash变量-预定义变量
- C#之AES256位加密解密
- p123.29t srand(5)排序
- hdu 4045 Machine scheduling 斯特林数+插板法
- Vim工作中常用命令-文本浏览篇
- Android数据的四种存储方式(1)SharedPreferences、SQLite、Content Provider和File 简介
- 利用Matlab将图片转换成素描(简笔画)风格
- “This text field does not specify an inputType ora hint” warning
- fun:限制表单域的输入内容格式
- 复数中的运算符重载(续)
- 工作日志5.4--5.7
- Android数据的四种存储方式(3)SharedPreferences