cf -148 b double追赶问题模拟

来源:互联网 发布:力高答题软件 编辑:程序博客网 时间:2024/06/05 18:43

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.
Example
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.

注意理解题意描述

#include <iostream>#include<algorithm>#include<cstring>#include<string>#include<cstdio>using namespace std;int main(){    int v1,v2,t,f,c;    cin>>v1>>v2>>t>>f>>c;    if(v1>=v2)        printf("0\n");    else    {        double x1,x2 = 0;        x1 = t*v1;        int sum = 0;         while(1)        {            double temp = x1/(v2-v1);            //printf("%d\n",1/2);            x1 += temp*v1;            if(x1>=c)            break;            sum++;            x1 += (x1/v2+f)*v1;        }        cout<<sum<<endl;    }    return 0;}

wr代码

#include <iostream>#include<algorithm>#include<cstring>#include<string>#include<cstdio>using namespace std;int main(){    int v1,v2,t,f,c;    cin>>v1>>v2>>t>>f>>c;    if(v1>=v2)        printf("0\n");    else    {        int x1,x2 = 0;        x1 = t*v1;        int sum = 0;        for(int tt=1;;tt++)        {            if(x1>=c)                break;            if(x1<=x2)            {                sum++;                x1+=v1*f;                x1+=x2*2/v2*v1;                continue;            }            x1+=v1;            x2+=v2;        }        cout<<sum<<endl;    }    return 0;}
原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 很久不说话了不敢说话了怎么办 宝宝2岁了还不会说话怎么办 2岁的宝宝还不会说话怎么办 小宝宝有四个月了母乳不够吃怎么办 一个月的宝宝吐奶厉害怎么办 新生儿吐奶吐一次吐的特别多怎么办 把孩子打了一次现在说话结巴怎么办 宝宝五岁了口吃越来越严重了怎么办 幼儿把自己的舌头扣破皮了怎么办 6岁宝贝烧到39度怎么办 2岁半的宝宝说话结巴怎么办 2周3宝宝不会说话胆小怎么办 宝宝我2岁多了说话有点结巴怎么办 两岁宝宝说话突然结巴了怎么办 两岁3宝宝叫她名字不理人怎么办 九个月的宝宝身高不达标怎么办 3岁宝宝又吐又拉怎么办 宝宝发烧39度怎么办手脚很烫 两岁宝宝吃什么吐什么怎么办 7岁宝宝吃多了吐怎么办 7个月的宝宝大便干燥怎么办 10个月宝宝便秘大便干燥怎么办 一岁半宝宝老是拉糊糊状大便怎么办 外阴部长了一个疙瘩有点痒怎么办 小孩打架被另一个小孩家人告怎么办 德保豆浆机有电但不工作怎么办 刚买的笔记本c盘不足怎么办 qq糖粘在喉咙气管里怎么办 穿上旗袍后感觉后腰处不平整怎么办 机打票给客人给错联怎么办?急 ps修证件照感觉不太立体怎么办 手机百度上下载的文档打不开怎么办 5岁宝宝乘飞机没带证件怎么办 网上订飞机票忘记订儿童票了怎么办 两岁宝宝对牛奶鸡蛋过敏了怎么办 两岁宝宝坐不住好跑怎么办 宝宝两岁多了不愿意坐小马桶怎么办 坐火车小孩拉屎在被子上怎么办 川航飞机票名字错了一个字怎么办 胜战本领怎么看走向战场怎么办 数数字油画你的颜料干了怎么办?