CDOJ 3 BiliBili, ACFun… And More! 模拟

原题链接:http://acm.uestc.edu.cn/#/problem/show/3

题意:

有个人在看B站视频时有个习惯,就是每当卡住的时候,他总再次从头开始看。另外,他在看视频时会先等待T的时间。现在给出播放的速度X和下载的速度Y,总长度S,问你他需要多少时间才能把整个视频都看完。

题解:

不断的跑追击问题就好,不过需要注意边界的情况。

代码:

#include<iostream>
#include<cstring>
#include<algorithm>
#include<iomanip>
using namespace std;

int X,Y,T,S;
int TT;

int main() {
    cin.sync_with_stdio(false);
    cin >> TT;
    int cas = 0;
    while (TT--) {
        cin >> X >> Y >> T >> S;
        cout<<"Case #"<<++cas<<": ";
        if (X <= Y || S <= Y * T) {
            cout << setprecision(3) << fixed << (double) S / X << endl;
            continue;
        }
        double L = Y * T;
        double now = 0;
        while (true) {
            double t = L / (X - Y);
            if (L + Y * t >= S) {
                now += (double) S / X;
                break;
            }
            now += t;
            L += Y * t;
        }
        cout << setprecision(3) << fixed << now << endl;
    }
    return 0;
}

 

转载于:https://www.cnblogs.com/HarryGuo2012/p/4843801.html

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值