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;
    }
  • 相关阅读:
    SQL语句的优化(转载)
    使用经纬度得到位置Geocorder
    android自带下拉刷新SwipeRefreshLayout
    线程池ScheduledThreadPool
    线程池SingleThreadPool
    线程池CachedThreadPool
    线程池FixedThreadPool
    线程池ThreadPoolExecutor
    Bitmap缩放(三)
    Bitmap缩放(二)
  • 原文地址:https://www.cnblogs.com/HarryGuo2012/p/4843801.html
Copyright © 2011-2022 走看看