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.
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.
1 2 1 1 10
2
1 2 1 1 8
1
题意:公主要从龙穴逃到城堡,公主的速度是vp m/h, 巨龙的速度是vd m/h, 巨龙在t小时后发现公主逃跑,开始追赶;当巨龙追上公主,公主扔掉一枚金币,巨龙拾起金币,返回龙穴,f小时后藏好金币,开始重新追赶公主;问公主至少需要带几枚金币才能逃回城堡;龙穴与城堡之间的距离为c;
注意:数据类型是double, 如果vp>=vd,需要零枚金币;
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <vector>
using namespace std;
int main(){
double pri, dra, t1, t2, dis;
cin >> pri >> dra >> t1 >> t2 >> dis;
if(pri>=dra){ //当时没加这个条件一直WA...;
cout << 0 << endl;
return 0;
}
double s=0;
int cnt=0;
s=pri*t1*1.0;
while(1){
s+=s/(dra-pri)*pri*1.0;
if(s>=dis) break;
cnt++;
double t=(s/dra+t2)*1.0;
s+=pri*t*1.0;
}
cout << cnt << endl;
return 0;
}