水题 Codeforces Round #105 (Div. 2) B. Escape

 

题目传送门

 1 /*
 2     水题:这题唯一要注意的是要用double,princess可能在一个小时之内被dragon赶上
 3 */
 4 #include <cstdio>
 5 #include <algorithm>
 6 #include <cstring>
 7 #include <cmath>
 8 #include <vector>
 9 #include <map>
10 using namespace std;
11 
12 const int MAXN = 1e4 + 10;
13 const int INF = 0x3f3f3f3f;
14 
15 int main(void)        //Codeforces Round #105 (Div. 2) B. Escape
16 {
17     //freopen ("B.in", "r", stdin);
18 
19     double vp, vd, t, f, c;
20     while (scanf ("%lf%lf%lf%lf%lf", &vp, &vd, &t, &f, &c) == 5)
21     {
22         if (vd <= vp)   puts ("0");
23         else
24         {
25             double cur = vp * t;   double d = 0;
26             int cnt = 0;
27             while (cur < c)
28             {
29                 if (cur + vp <= d + vd)
30                 {
31                     double time = (cur - d) / (vd - vp);
32                     if (cur + time * vp >= c)   break;
33                     cur += vp * (time + (d + vd * time) / vd + f);  d = 0;
34                     cnt++;
35                 }
36                 else
37                 {
38                     cur += vp;  d += vd;
39                 }
40             }
41 
42             printf ("%d\n", cnt);
43         }
44     }
45 
46     return 0;
47 }

 

posted @ 2015-07-18 12:55  Running_Time  阅读(158)  评论(0编辑  收藏  举报