cdoj 03 BiliBili, ACFun… And More! 水题

Article

Time Limit: 20 Sec  Memory Limit: 256 MB

题目连接

http://acm.uestc.edu.cn/#/problem/show/3

Description

Some of you may have already noticed, there is a team in our final contest whose name is UESTC_BiliBilii, with user id as ACfun. Actually, both of them are websites mainly for watching videos.

So in this problem we also deal with video-share websites. When watching videos online, two numbers are very important. One is the playing speed: the speed you play the video, say X KB per second. The other is the downloading speed: the speed the computer downloads the video from the internet, say Y KB per second. Obviously, if X>Y, then you may have to pause for some time, since you cannot play something that hasn’t been downloaded!

The playing speed can also be described as the moving speed of the circle at the bottom of the videos, see the pictures below.

The circle will move along the blue bar, which is full now, indicating that downloading is already complete.

In this problem, we suppose that X and Y will always be constant.

Kennethsnow has a special habit when watching videos, let me tell you. First of all, he will wait for some time to download part of the video, say T seconds. Then, he starts to play the video.

If at a certain time, the video is paused, then kennethsnow will move the cursor(The circle in the picture) instantly to the leftmost position! That means, he will watch the video again, from the very beginning.

He will do this again and again, until the video comes to an end. Given X, Y, T, and the total size of the video, what is the time kennethsnow needs, to finish his watching?

Since
World crashes too often, now he is asking his friend ATM for the
optimal strategy to input his article. A strategy is measured by its
expectation keys DRD needs to press.

Note that DRD can press a key at fast enough speed

Input

The first line of input contains a number T, indicating the number of test cases. (T≤1000).For each case, there will be four integers X, Y, T and S, which is the playing speed, downloading speed, the time kennethsnow will wait before playing, and the total size of video, given in KB. (1≤X,Y,T≤20, 1≤S≤100).

Output

For each case, output Case #i: first. (i is the number of the test case, from 1 to T). Then output the time kennethsnow needs to finish watching, in decimals, round to 3 decimal places.

Sample Input

3 1 1 2 10 2 1 3 20 3 1 4 30

Sample Output

Case #1: 10.000
Case #2: 19.000
Case #3: 26.250

HINT

题意

有一个人在bilibili看动漫,看的速度是x,下载的速度是y,一开始等了t秒再播放的,视频总大小为x

然后这个人有个怪癖,就是当出现卡顿的时候,他就会把进度条重新拉回开始位置

然后问你得过多少秒,才能看完整个视频

题解:

高中物理题,随便推推就好啦~

代码:

//qscqesze
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <queue>
#include <typeinfo>
#include <fstream>
#include <map>
#include <stack>
typedef long long ll;
using namespace std;
//freopen("D.in","r",stdin);
//freopen("D.out","w",stdout);
#define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
#define test freopen("test.txt","r",stdin)
#define maxn 200
#define mod 10007
#define eps 1e-9
int Num;
char CH[20];
const int inf=0x3f3f3f3f;
const ll infll = 0x3f3f3f3f3f3f3f3fLL;
inline ll read()
{
    ll x=0,f=1;char ch=getchar();
    while(ch<‘0‘||ch>‘9‘){if(ch==‘-‘)f=-1;ch=getchar();}
    while(ch>=‘0‘&&ch<=‘9‘){x=x*10+ch-‘0‘;ch=getchar();}
    return x*f;
}
inline void P(int x)
{
    Num=0;if(!x){putchar(‘0‘);puts("");return;}
    while(x>0)CH[++Num]=x%10,x/=10;
    while(Num)putchar(CH[Num--]+48);
    puts("");
}
//**************************************************************************************

double x,y,t,z;
double cal(double v1,double v2,double s)
{
    return s/(v1-v2);
}
void solve()
{
    cin>>x>>y>>t>>z;
    if(y>=x)
    {
        printf("%.3lf\n",z/x);
        return;
    }
    double ans=0;
    double kiss=y*t;
    while(cal(x,y,kiss)<z/x)
    {
        ans+=cal(x,y,kiss);
        kiss=cal(x,y,kiss)*x;
    }
    printf("%.3lf\n",ans+z/x);
}
int main()
{
    //test;
    int t=read();
    for(int cas=1;cas<=t;cas++)
    {
        printf("Case #%d: ",cas);
        solve();
    }
}
时间: 2024-11-25 08:22:02

cdoj 03 BiliBili, ACFun… And More! 水题的相关文章

UESTCOJ-BiliBili, ACFun… And More!(水题)

BiliBili, ACFun… And More! Time Limit: 3000/1000MS (Java/Others)     Memory Limit: 65535/65535KB (Java/Others) Some of you may have already noticed, there is a team in our final contest whose name is UESTC_BiliBilii, with user id as ACfun. Actually,

cdoj 24 8球胜负(eight) 水题

8球胜负(eight) Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://acm.uestc.edu.cn/#/problem/show/24 Description 8球是一种台球竞赛的规则.台面上有7个红球.7个黄球以及一个黑球,当然还有一个白球.对于本题,我们使用如下的简化规则:红.黄两名选手轮流用白球击打各自颜色的球,如果将该颜色的7个球全部打进,则这名选手可以打黑球,如果打进则算他胜.如果在打进自己颜色的所有球之前就把黑球打进,则

CDOJ 3 BiliBili, ACFun… And More! 解题报告

好吧,我还是回来了,竞赛结束后也没怎么碰那个unnamed.space了,现在早就已经过期了.同样的几个月没有碰OI了,手明显生疏很多,毕业了重新搞搞OI吧,想必落下了很多. 高考考得很渣,不过很荣幸自主招生进了电子科技大学某郫县男子技校,于是去他们的OJ上围观了一下,随便做几题玩玩. 嘛,嘛,不提了,我来讲讲CDOJ 3的大致做法,很明显的追及问题,因为数据很小,\(O(n)\)暴力可过,然而推公式的话,也是有\(O(1)\)的做法的. 这里我没有用暴力(我是做完后对拍才到网上搜到的暴力做法…

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> #

cdoj 26 遮挡判断(shadow) 水题

遮挡判断(shadow) Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://acm.uestc.edu.cn/#/problem/show/26 Description 在一个广场上有一排沿着东西方向排列的石柱子,阳光从东边以一定的倾角射来(平行光).有的柱子可能被在他东边的高大的柱子的影子给完全遮挡住了.现在你要解决的问题是求出有多少柱子是没有被完全遮挡住的. 假设每个石柱子是一根细棒,而且都垂直于地面摆放. Input 输入包含多组数据

Codeforces Round #113 (Div. 2)E---Tetrahedron(矩阵,水题)

You are given a tetrahedron. Let's mark its vertices with letters A, B, C and D correspondingly. An ant is standing in the vertex D of the tetrahedron. The ant is quite active and he wouldn't stay idle. At each moment of time he makes a step from one

ZOJ1058 Currency Exchange【水题】

Currency Exchange Time Limit: 2 Seconds Memory Limit: 65536 KB When Issac Bernand Miller takes a trip to another country, say to France, he exchanges his US dollars for French francs. The exchange rate is a real number such that when multiplied by th

2015南阳CCPC L - Huatuo&#39;s Medicine 水题

L - Huatuo's Medicine Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 无 Description Huatuo was a famous doctor. He use identical bottles to carry the medicine. There are different types of medicine. Huatuo put medicines into the bottles and chain these b

sdut 2841 Bit Problem (水题)

题目 贴这个题是因为看题解有更简单的方法, 我做的时候是直接算的, 也很简单. 贴一下题解吧: 如果一个整数不等于 0,那么该整数的二进制表示中至少有一位是 1. 这个题结果可以直接输出 x - (x&(x-1)); 因为x-1 之后二进制下,就是最右边的1变成了0, 最右边的1的 右边所有的0变成了1, 不影响最左边. 我的代码: 1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4