cdoj 03 BiliBili, ACFun… And More! 水题
Article
Time Limit: 20 Sec Memory Limit: 256 MB
题目连接
http://acm.uestc.edu.cn/#/problem/show/3
Description
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(); } }