CodeForces 148BEscape
来源:互联网 发布:老王python培训 编辑:程序博客网 时间:2024/06/06 04:25
Description
The princess is going to escape the dragon's cave, and she needs to plan it carefully.
The princess runs at vp miles per hour, and the dragon flies at vd miles per hour. The dragon will discover the escape after t hours and will chase the princess immediately. Looks like there's no chance to success, but the princess noticed that the dragon is very greedy and not too smart. To delay him, the princess decides to borrow a couple of bijous from his treasury. Once the dragon overtakes the princess, she will drop one bijou to distract him. In this case he will stop, pick up the item, return to the cave and spend f hours to straighten the things out in the treasury. Only after this will he resume the chase again from the very beginning.
The princess is going to run on the straight. The distance between the cave and the king's castle she's aiming for is c miles. How many bijous will she need to take from the treasury to be able to reach the castle? If the dragon overtakes the princess at exactly the same moment she has reached the castle, we assume that she reached the castle before the dragon reached her, and doesn't need an extra bijou to hold him off.
Input
The input data contains integers vp, vd, t, f and c, one per line (1 ≤ vp, vd ≤ 100, 1 ≤ t, f ≤ 10, 1 ≤ c ≤ 1000).
Output
Output the minimal number of bijous required for the escape to succeed.
Sample Input
121110
2
12118
1
Hint
In the first case one hour after the escape the dragon will discover it, and the princess will be 1 mile away from the cave. In two hours the dragon will overtake the princess 2 miles away from the cave, and she will need to drop the first bijou. Return to the cave and fixing the treasury will take the dragon two more hours; meanwhile the princess will be 4 miles away from the cave. Next time the dragon will overtake the princess 8 miles away from the cave, and she will need the second bijou, but after this she will reach the castle without any further trouble.
The second case is similar to the first one, but the second time the dragon overtakes the princess when she has reached the castle, and she won't need the second bijou.
题意博主就不细说了,......做了之后发现就是个纯粹的模拟题...具体步骤代码中说就可以了。可能是组队赛打多了,喜欢一道题扣个差不多,水题都没看......
注意:
1.虽然给定的是整数,但是存在速度和路程不成倍数的情况,所以要用实数。
#include <iostream>#include <cstdio>#include <cmath>#include <algorithm>using namespace std;int main(){ int vp,vd,t,f,c; scanf("%d%d%d%d%d",&vp,&vd,&t,&f,&c); if(vd<=vp)puts("0");//这种情况龙永远追不上公主 else { int g=vd-vp;//龙追公主的相对速度 double sum=0; int ans=0; sum+=t*1.0*vp;//最初公主先走的路程 sum+=(sum/g)*vp;//第一次龙开始追赶 while(sum<c) { ans++;//两个碰面,表示这个时候还没走完,要使用一次高科技 double x=vp*(f+sum/vd);//龙返回并且要待上f个小时 sum+=x; //这之后才从起点开始追逐 sum+=(sum/g)*vp; } printf("%d\n",ans); } return 0;}
比较水的模拟.....
- CodeForces 148BEscape(数学)
- CodeForces 148BEscape
- codeforces 148 div1
- codeforces 148 div2 B
- codeforces 148 div2 C
- Codeforces 148E(Porcelain)
- CodeForces 148B - Escape
- codeforces 148 A
- Codeforces 148E. Porcelain
- CodeForces 148E Porcelain
- Codeforces Round #148
- 【DP】CodeForces 148D
- codeforces 148E
- CodeForces 148AInsomnia cure
- codeforces-148B-Escape
- CodeForces 148A
- codeforces 148c
- CodeForces 148D
- Java-TCP/IP编程-03 消息群发功能
- 【类库】java时间操作类库:Joda-Time
- 《OpenGL ES 2.0 Programming Guide》第9章 “最简单的本地纹理显示”示例代码【C语言版】
- Java-TCP/IP编程-04 带窗口的群聊天功能
- 文件结构图
- CodeForces 148BEscape
- linux(CVE-2010-3847)漏洞和利用方法
- u盘安装centos6
- 对象转换为JSON数据格式&使用JQuery获取数据
- 深度解析CentOS通过日志反查入侵
- 120. Triangle
- Linux系统日志及日志分析
- Android context.getSystemService()浅析
- HDU 4417 Super Mario(2012杭州网络赛 H 离线线段树)