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, 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?

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 and output

Sample Input Sample Output
3
1 1 2 10
2 1 3 20
3 1 4 30
Case #1: 10.000
Case #2: 19.000
Case #3: 26.250

好久没有刷题了,最近又因为考试,就只能偶尔刷刷水题。题意不说了,在纸上画一下利用物理知识就能解决了。

 #include<stdio.h>
int main ()
{
int i=;
double t0,x,y,t,s;
double time,t1,xTime,yTime,catchtime;
scanf("%lf",&t0);
while(t0--){
scanf("%lf%lf%lf%lf",&x,&y,&t,&s);
time=;
xTime=;
yTime=t;
if(x<=y) time+=s/x;
else{
catchtime=y*t/(x-y);
while(catchtime<s/x){
xTime+=catchtime;
yTime+=catchtime;
catchtime=y*yTime/(x-y);
}
time+=xTime+s/x;
}
printf("Case #%d: %.3f\n",i++,time);
}
return ;
}

UESTCOJ-BiliBili, ACFun… And More!(水题)的更多相关文章

  1. cdoj 03 BiliBili, ACFun… And More! 水题

    Article Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://acm.uestc.edu.cn/#/problem/show/3 Descr ...

  2. HDOJ 2317. Nasty Hacks 模拟水题

    Nasty Hacks Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Tota ...

  3. ACM :漫漫上学路 -DP -水题

    CSU 1772 漫漫上学路 Time Limit: 1000MS   Memory Limit: 131072KB   64bit IO Format: %lld & %llu Submit ...

  4. ytu 1050:写一个函数,使给定的一个二维数组(3×3)转置,即行列互换(水题)

    1050: 写一个函数,使给定的一个二维数组(3×3)转置,即行列互换 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 154  Solved: 112[ ...

  5. [poj2247] Humble Numbers (DP水题)

    DP 水题 Description A number whose only prime factors are 2,3,5 or 7 is called a humble number. The se ...

  6. gdutcode 1195: 相信我这是水题 GDUT中有个风云人物pigofzhou,是冰点奇迹队的主代码手,

    1195: 相信我这是水题 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 821  Solved: 219 Description GDUT中有个风云人 ...

  7. BZOJ 1303 CQOI2009 中位数图 水题

    1303: [CQOI2009]中位数图 Time Limit: 1 Sec  Memory Limit: 162 MBSubmit: 2340  Solved: 1464[Submit][Statu ...

  8. 第十一届“蓝狐网络杯”湖南省大学生计算机程序设计竞赛 B - 大还是小? 字符串水题

    B - 大还是小? Time Limit:5000MS     Memory Limit:65535KB     64bit IO Format: Description 输入两个实数,判断第一个数大 ...

  9. ACM水题

    ACM小白...非常费劲儿的学习中,我觉得目前我能做出来的都可以划分在水题的范围中...不断做,不断总结,随时更新 POJ: 1004 Financial Management 求平均值 杭电OJ: ...

随机推荐

  1. C++ Socket TCP "Hello World!"

    这是C++ SOCKET网络程序中的C/S结构之TCP "Hello World !",共两个控制台工程: //////////////////////////////////// ...

  2. C++的try catch到底能防止什么错误?

    我在.h文件里定义:    LoadingWidget* w;然后.cpp文件里定义: void MyClass::ModifyTask(){    // w = new LoadingWidget( ...

  3. LinkedHashMap和HashMap的比较使用 由于现在项目中用到了LinkedHashMap,并不是太熟悉就到网上搜了一下。 ? import java.util.HashMap; impo

    LinkedHashMap和HashMap的比较使用 由于现在项目中用到了LinkedHashMap,并不是太熟悉就到网上搜了一下. import java.util.HashMap; import ...

  4. Apache benchmark 压力测试工具

    ab 的全称是 ApacheBench , 是 Apache 附带的一个小工具 , 专门用于 HTTP Server 的 benchmark testing , 可以同时模拟多个并发请求. 安装apa ...

  5. ubuntu下eclipse突然崩溃,解决办法

    rm YOUR_WORKSPACE/.metadata/.plugins/org.eclipse.core.resources/.snap 抛出的一场如下: !SESSION 2013-09-30 1 ...

  6. How to: Use a Custom User Name and Password Validator

    在wcf中使用自定义的用户名和密码验证方式 https://msdn.microsoft.com/en-us/library/aa702565.aspx http://www.codeproject. ...

  7. eclipse android重新安装遇到各种问题

    1.JAVA_HOME环境变量失效的解决办法 原文网址:http://www.cnblogs.com/yjmyzz/p/3521554.html 晚上把oracle自带的weblogic给卸载了,然后 ...

  8. AKKA初体验

    关于thread和actor下面这段话讲的很好Experienced developers have learned to be very careful with unrestricted thre ...

  9. 洛谷1377 M国王 (SCOI2005互不侵犯King)

    洛谷1377 M国王 (SCOI2005互不侵犯King) 本题地址:http://www.luogu.org/problem/show?pid=1377 题目描述 天天都是n皇后,多么无聊啊.我们来 ...

  10. Bzoj 1976: [BeiJing2010组队]能量魔方 Cube 最小割,最大流

    1976: [BeiJing2010组队]能量魔方 Cube Time Limit: 10 Sec  Memory Limit: 64 MBSubmit: 879  Solved: 304[Submi ...