【罗书】HDU 3233 Download Manager(水题)

Jiajia downloads a lot, a lot more than you can even imagine. Some say
that he starts downloading up to 20,000 files together. If 20,000
files try to share a limited bandwidth then it will be a big hazard
and no files will be downloaded properly. That is why, he uses a
download manager.

If there are T files to download, the download manger uses the
following policy while downloading files:

  1. The download manager gives the smaller files higher priority, so it starts downloading the smallest n files at startup. If there is a tie,
    download manager chooses the one with less bytes remaining (for
    download). We assume that with at least 50 Mega Bytes/sec of
    bandwidth, n files can be downloaded simultaneously without any
    problem.

  2. The available bandwidth is equally shared by the all the files that are being downloaded. When a file is completely downloaded its
    bandwidth is instantaneously given to the next file. If there are no
    more files left except the files that are being downloaded, this
    bandwidth is immediately shared equally by all remaining files that
    are being downloaded.

Given the size and completed percentage of each file, your task is to
intelligently simulate the behavior of the download manager to find
the total time required to download all the files. Input The will be
at most 10 test cases. Each case begins with three integers T (1 <= T
<= 20000), n (1 <= n <= 2000 and 1 <= n <= T) and B (50 <= B <= 1000).
Here B denotes the total bandwidth available to Jiajia (In
Megabytes/sec). Please note that the download manager always downloads
n files in parallel unless there are less than n files available for
download. Each of next T lines contains one non-negative
floating-point number S (less than 20,000, containing at most 2 digits
after the decimal places) and one integer P (0 <= P <= 100). These two
numbers denote a file whose size is S megabyte and which has been
downloaded exactly P% already. Also note that although theoretically
it is not possible that the size of a file or size of its remaining
part is a fraction when expressed in bytes, for simplicity please
assume that such thing is possible in this problem. The last test case
is followed by T=n=B=0, which should not be processed. Output For each
case, print the case number and the total time required to download
all the files, expressed in hours and rounded to 2 digits after the
decimal point. Print a blank line after the output of each test case.
Sample Input 6 3 90
100.00 90
40.40 70
60.30 70
40.40 80
40.40 85
40.40 88 1 1 56
12.34 100 0 0 0 Sample Output Case 1: 0.66

Case 2: 0.00

刚开始用cinTLE了,诡异

题目大意:模拟一个下载器,给出最大带宽和最大下载文件个数和单个文件的大小以及下载百分比,让求时间

直接把文件的总大小求出来除以带宽就好了

AC的代码

#include <bits/stdc++.h>
using namespace std;
int t,n,b;

int main(){
    int cot=0;
    while(~scanf("%d%d%d",&t,&n,&b)){
        if(!t||!n||!b) break;
    double sum=0;
    double s,p;
    for(int i=1;i<=t;i++){
        scanf("%lf",&s);
        scanf("%lf",&p);
        sum+=0.01*(s*(100.0-p));  //计算文件总剩余
    } 
    double time;
        time=sum/b;
        printf("Case %d: %.2lf\n\n",++cot,time); 
    }
    //cin.get();
    return 0;
}


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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值