水题 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 }

 

转载于:https://www.cnblogs.com/Running-Time/p/4656687.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值