【CF#148B】Escape(模拟)

题干:

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.

Examples

Input

1
2
1
1
10

Output

2

Input

1
2
1
1
8

Output

1

Note

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.

题目大意:公主逃跑的速度为vp,龙追赶的速度为vd,公主逃跑之后龙要经过t秒发现。如果龙追上的公主,公主使用道具,龙将原速返回cave,并且f秒之后重新追出。cave和城堡之间有c米距离,问公主至少需要使用道具几次。

ps: 
1. 如同时到达城堡,则算公主逃脱成功 
2. 公主速度比龙快,那么龙永远也追不上

注意  : 我忘记加龙返回cave的同时,公主前进的路程。p和d判断的时候,如果使用EPS=1e-8好像出现未知bug

解题报告:

     按照题意模拟过程,注意用double。

AC代码:

#include<iostream>
#include<cstdio> 
using namespace std;
int main()
{double p,d,t,f,c;scanf("%lf%lf%lf%lf%lf",&p,&d,&t,&f,&c);if(p>=d) {printf("0\n");return 0 ;}double cur=0;cur+=t*p;int sum=0;double t1;t1=cur/(d-p);cur+=t1*p;double t2=0;while(cur<c){sum++;t2=cur/d;cur+=t2*p;cur+=f*p;t1=cur/(d-p);cur+=t1*p;}cout <<sum <<endl;return 0 ;} 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/442016.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

mysql sql语句分页查询_如何用sql语句 实现分页查询?

我制作了一个数据库其中一张表createtablenews(news_idintprimarykeyidentity(1,1),news_titlevarchar(50)notnull,news_authorvarchar(20),news_summaryvarchar(50),news_contenttext...我制作了一个数据库其中一张表create table news(news_id int primary key identity(1,1)…

*【HDU - 1042 】 N! (大数乘法)

题干&#xff1a; Given an integer N(0 ≤ N ≤ 10000), your task is to calculate N! Input One N in one line, process to the end of file. Output For each N, output N! in one line. Sample Input 1 2 3 Sample Output 1 2 6 解题报告&#xff1a; 大数运…

【bzoj 1754】【POJ - 2389 】Bull Math (高精度运算)

题干&#xff1a; Bulls are so much better at math than the cows. They can multiply huge integers together and get perfectly precise answers ... or so they say. Farmer John wonders if their answers are correct. Help him check the bulls answers. Read in two…

mysql居左查询abcd_数据库--查询语句

查询语句mysql中要学习的知识&#xff1a;多表关系&#xff0c;查询语句&#xff0c;索引添加数据补充将一个查询结果插入到另一张表中create table student(name char(10), gender int);insert into student values(nalituo, 1);insert into student values(sasigi, 0);create…

druid mysql配置详解_druid 参数配置详解

spring.datasource.typecom.alibaba.druid.pool.DruidDataSource#驱动配置信息spring.datasource.driver-class-namecom.mysql.jdbc.Driver#基本连接信息spring.datasource.username rootspring.datasource.password rootspring.datasource.urljdbc:mysql://192.168.153.23:3…

【POJ - 2376】Cleaning Shifts (贪心)

题干&#xff1a; Farmer John is assigning some of his N (1 < N < 25,000) cows to do some cleaning chores around the barn. He always wants to have one cow working on cleaning things up and has divided the day into T shifts (1 < T < 1,000,000), …

mysql sql 片段_MySQL代码片段

1.[代码][SQL]代码--导出为xml文件mysql -X -uroot -proot -e "use testa;select * from test_tb;" > /opt/test.xml--导出为csv文件--fields terminated 分割记录中每个字段的字符--optionally enclosed 包围每个字段的字符--lines terminated 每行结束的字符--P…

【HDU - 4990】 Reading comprehension (构造+矩阵快速幂)

题干&#xff1a; Read the program below carefully then answer the question. #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include<iostream> #include <cstring> #include <cmath> #include &…

finereport文本框如何实现多值查询_如何实现参数级联查询

参数级联查询是查询控件之间的一种互动方式&#xff0c;比如在某个下拉框选定选项后&#xff0c;另一个下拉框里的选项范围会随之变化。润乾报表提供了多种编辑风格&#xff0c;每种编辑风格都有丰富的属性&#xff0c;以此为基础实现参数级联查询也很简单。下面就通过一个例子…

【HDU - 5015 】233 Matrix (矩阵快速幂)

题干&#xff1a; In our daily life we often use 233 to express our feelings. Actually, we may say 2333, 23333, or 233333 ... in the same meaning. And here is the question: Suppose we have a matrix called 233 matrix. In the first line, it would be 233, 233…

【HDU - 2899】 Strange fuction(二分或三分,求导)

题干&#xff1a; Now, here is a fuction: F(x) 6 * x^78*x^67*x^35*x^2-y*x (0 < x <100) Can you find the minimum value when x is between 0 and 100. Input The first line of the input contains an integer T(1<T<100) which means the number of…

php mysql html标签_HTML标签格式化PHP和MySQL

我有这个MySQL语句Select type.type, color.color, ShotName, Item.name, Item.Item_idFrom typeInner Join ItemOn type.type_id Item.type_idInner Join colorOn color.color_id Item.color_idWhere Item.state0 And Item.offline 0Group By color.color, Item.name, type.o…

【CF#706B】 Interesting drink (二分)

题干&#xff1a; 瓦西里喜欢在努力工作后休息&#xff0c;所以你可能经常在附近的一些酒吧见到他。他喜欢 "Beecola"&#xff0c;可以从 n 个不同的商店买到。在第 i 个商店的价格为 xi 元。 瓦西里计划购买他最喜欢的饮料 q 次。在第 i 天他能花 mi 元。他想知道每…

mysql datetime month不走索引_like百分号加前面一定不走索引吗?一不小心就翻车,关于mysql索引那些容易错的点...

like百分号加前面一定不走索引吗&#xff1f;正常来讲&#xff0c;我们都知道在mysql的like查询中&#xff0c;百分号加在关键词后面是走索引的&#xff0c;比如 select * like "张三%"&#xff0c;而百分号在前面是不走索引的&#xff0c;比如 select * like "…

ACM竞赛、数论内容常用的定理(求解(a/b)%c,乘法逆元,费马小定理)

如果b与c互素&#xff0c;则(a/b)%ca*b^((c)-1)%c其中是欧拉函数。或者(a/b)%ca*b^(c-2)%c 如果b与c不互素&#xff0c;则(a/b)%c(a%bc)/b 对于b与c互素和不互素都有(a/b)%c(a%bc)/b成立 乘法逆元用扩展欧几里得定理&#xff1a; 例题&#xff1a;ZOJ - 3609 题干&#xf…

自定义菜单url不能带_微服务架构【SpringBoot+SpringCloud+VUE】五 || 实战项目微信公众号自定义开发...

本章主要讲解微信公众号自定义菜单、微信网页开发、模板消息推送等功能的实现&#xff1b;发福利了&#xff0c;下方关注公众号&#xff0c;就能免费获取项目源码1、自定义菜单开发前需要了解以下几点&#xff1a;1、微信公众号的自定义菜单最多包括3个一级菜单&#xff0c;每个…

C语言编程中关于负数的%运算的判定。

如果 % 两边的操作数都为正数&#xff0c;则结果为正数或零&#xff1b;如果 % 两边的操作数都是负数&#xff0c;则结果为负数或零。C99 以前&#xff0c;并没有规定如果操作数中有一方为负数&#xff0c;模除的结果会是什么。C99 规定&#xff0c;如果 % 左边的操作数是正数&…

mnesia mysql性能,Mnesia数据库的存储容量是多少?

Some places state 2GB period. Some places state it depends up the number of nodes.解决方案Quite large if your question is "whats the storage capacity of an mnesia database made up of a huge number of disc_only_copies tables" - youre largely limit…

无数种求逆元的方法总结

乘法逆元 对于缩系中的元素&#xff0c;每个数a均有唯一的与之对应的乘法逆元x&#xff0c;使得ax≡1(mod n) 一个数有逆元的充分必要条件是gcd(a,n)1&#xff0c;此时逆元唯一存在 逆元的含义&#xff1a;模n意义下&#xff0c;1个数a如果有逆元x&#xff0c;那么除以a相当于…

【CF#2A】Winner(模拟 STL-map)☆

题干&#xff1a; The winner of the card game popular in Berland "Berlogging" is determined according to the following rules. If at the end of the game there is only one player with the maximum number of points, he is the winner. The situation be…