Escape
来源:互联网 发布:中转国际机票 知乎 编辑:程序博客网 时间:2024/06/07 02:52
把路程的计算公式推导出来就行了
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 vdmiles 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.
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 the minimal number of bijous required for the escape to succeed.
121110
2
12118
1
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.
#include<stdio.h>#define eps 1e-6int main(){double p,d,t,f,c;double dis=0;int num=0;scanf("%lf%lf%lf%lf%lf",&p,&d,&t,&f,&c);if(p>=d||t*p>=c)printf("0");else{dis+=t*p;while(c-dis>eps){t=dis/(d-p);dis+=t*p;if(c-dis<eps){printf("%d",num);break;}elsenum++;dis+=(t+f)*p;if(c-dis<eps){printf("%d",num);break;}}}return 0;}
- escape
- escape
- escape
- Escape
- Escape
- Escape
- javaScript:Escape()
- escape() 方法:
- escape sequence
- Escape Problem
- Escape Sandy
- Escape Rout
- JS escape
- js escape
- Escape Sequences
- oracle escape
- hdu1733(Escape)
- [Sdoi2013]escape
- 深入學習zip() ,能使用列表,元組,但不能使用字典
- 反转链表
- JAVA知识点梳理第一部分——常规知识
- iOS开发笔记--UITableViewCell的选中时的颜色及tableViewCell的selecte与deselecte
- 使用BitSet对1000万个Int整数进行排序
- Escape
- springmvc中文乱码
- mysql数据库
- Java Web书籍推荐
- 最全Pycharm教程(16)——Pycharm编辑器功能之代码自动生成
- 51Nod
- NOIP模拟9.12
- linux重定向输入和输出
- mysql连接查询