zoukankan      html  css  js  c++  java
  • 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;
    }
  • 相关阅读:
    苹果手机的SB系列(9)移动版的AAP个个都比桌面版大?
    初识Redis(四)
    初识Redis(三)
    初识Redis(二)
    初识Redis(一)
    Codeforces Round #589 (Div. 2)
    康拓展开学习笔记
    最短路模板
    K
    D
  • 原文地址:https://www.cnblogs.com/HarryGuo2012/p/4843801.html
Copyright © 2011-2022 走看看