HDU 5872 Seats 2016大连网赛

14 篇文章 0 订阅
4 篇文章 0 订阅
Seats
Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 262    Accepted Submission(s): 83


Problem Description
The yearly sports meeting is approaching in Hail university and M departments, conveniently numbered from 1 to M, are going to take part in. Each department has no more than h students.
  Now send ai students from the i-th department as spectators, such that ∑i=1Mai=L. There are k seats every row on the grandstand and Lmodk=0. Students from the same department are required to sit in the same row. The question is how many rows should be arranged at least, to ensure that no matter of the values of M and a1,⋯,am, all the students will be able to get seated.


Input
Multiple test cases, process till end of input.

  For each case, the one and only line contains three space-separated integers h,L,k as stated above.

  You can assume that

     0<h≤1000

     0<L≤1000000000,

     0<k≤1000000, and

     Lmodk=0.


Output
Output a positive integer X on a single line showing the least rows needed.


Sample Input

39 2020 202



Sample Output

12



Source
2016 ACM/ICPC Asia Regional Dalian Online

贪心
考虑
ai=num //i<=n-1
an=L%num
显然 每排最多只能放k/h个部门
当k/num=k/h 且num最小时
需要的排数最多

#include<iostream>
#include<stdlib.h>
#include<stdio.h>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<algorithm>
#include<set>
#include<map>
#include<stack>
#include<time.h>
#include<math.h>
#include<list>
#include<cstring>
#include<fstream>
//#include<memory.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define INF 1000000007
#define pll pair<ll,ll>
#define pid pair<int,double>

int main()
{
    //freopen("/home/lu/文档/r.txt","r",stdin);
    //freopen("/home/lu/文档/w.txt","w",stdout);
    int h,L,k;
    while(~scanf("%d%d%d",&h,&L,&k)){
        int t=k/h;//每排最多t个部门
        int num=k/(t+1)+1;//一排最多放t个部门 则每个部门最少有num人
        t=k/num;
        t=t*num;//每排有t人
        int ans=L/t+(L%t>0);//能放多少排
        printf("%d\n",ans);
    }
    return 0;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值