本文共 974 字,大约阅读时间需要 3 分钟。
1 /* 2 水题:这题唯一要注意的是要用double,princess可能在一个小时之内被dragon赶上 3 */ 4 #include 5 #include 6 #include 7 #include 8 #include 9 #include 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. Escape16 {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 else24 {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 else37 {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