HDU 5872 - Seats

54 篇文章 0 订阅
17 篇文章 0 订阅

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

题意:有好多班级要去参加一个会议,给出h表示每个班级的最多人数,L表示会场的人数,k表示每排的座位数,问最少的排数。

一下解析都是猜测,居然过了。。。

目的就是要让每个班级人数尽量一样,而每排空出的人数尽量多。首先每个班级若按照最大人数每排能坐多少个班级,然后每排多坐一个班级每班级多少人,这样每班的人数就是这个人数 +1。然后算出有多少排,如果不能正好完全坐好,就多坐一排。

#include <cstdio>

int main()
{
    int h, L, K;
    while (scanf("%d%d%d", &h, &L, &K) != EOF)
    {
        int num = K/h;
        h = K/(num + 1);
        int H = h + 1;
        int rows = L/(K - K%H);
        if (L % (K - K%H) > 0)
            rows++;
        printf("%d\n", rows);
    }
    return 0;
}


 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值