CodeForces 148B Escape

Escape

Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u

Submit Status Practice CodeForces 148B

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

Input

121110

Output

2

Input

12118

Output

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<stdio.h>
 2 #include<string.h>
 3 int main()
 4 {
 5     double Vp,Vd,t,f,c;
 6     while(scanf("%lf %lf %lf %lf %lf",&Vp,&Vd,&t,&f,&c)!=EOF)
 7     {
 8         float s;
 9         int n=0;
10         if(Vp>=Vd)
11             n=0;
12         else
13         {
14             s=((Vp*t/(Vd-Vp))*Vd);
15             while(s<c)
16             {
17                 n++;
18                 s=((s+(s/Vd+f)*Vp)/(Vd-Vp))*Vd;
19             }
20         }
21         printf("%d\n",n);
22     }
23     return 0;
24 }

时间: 2024-10-09 09:39:18

CodeForces 148B Escape的相关文章

Codeforces 932F - Escape Through Leaf

Problem Link: http://codeforces.com/contest/932/problem/F Problem Statement: F. Escape Through Leaf time limit per test: 3 seconds memory limit per test:256 megabytes input: standard input output: standard output You are given a tree with n nodes (nu

Codeforces 264A. Escape from Stones

Squirrel Liss lived in a forest peacefully, but unexpected trouble happens. Stones fall from a mountain. Initially Squirrel Liss occupies an interval [0,?1]. Next, n stones will fall and Liss will escape from the stones. The stones are numbered from

CodeForces 264A Escape from Stones dfs

题目链接:点击打开链接 题意:开始有一个区间[0,1] 每次操作在中间填i,然后选择坐半段或者右半段(给出选择的方案,然后从左到右输出填写的i) (i=1 2 3···) #include <cstdio> char s[1000005]; void dfs(int x){ if(s[x] == 0)return ; if(s[x] == 'l') { dfs(x+1); printf("%d\n", x+1); } else { printf("%d\n&quo

寒假训练3解题报告 CodeForces #148

CodeForces 148B 一道简单模拟,判断龙能够抓到公主几次,如果公主和龙同时到达公主的城堡,不算龙抓住她,因为路程除以速度可能会产生浮点数,所以这里考虑一下精度问题 1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #include <iomanip> 5 #include <algorithm> 6 using namespace std; 7 #defi

CodeForces Gym 101047E Escape from Ayutthaya BFS

Escape from Ayutthaya Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Gym 101047E Description standard input/output Ayutthaya was one of the first kingdoms in Thailand, spanning since its foundation in 1350 to its collaps

Codeforces Round #162 (Div. 1) A. Escape from Stones

A. Escape from Stones time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Squirrel Liss lived in a forest peacefully, but unexpected trouble happens. Stones fall from a mountain. Initially Squ

Codeforces Round #105 (Div. 2) (ABCDE题解)

比赛链接:http://codeforces.com/contest/148 比较简单的一场,最长的一题也才写了30行多一点 A. Insomnia cure time limit per test:2 seconds memory limit per test:256 megabytes ?One dragon. Two dragon. Three dragon?, - the princess was counting. She had trouble falling asleep, and

[CCPC2019秦皇岛] E. Escape

[CCPC2019秦皇岛E] Escape Link https://codeforces.com/gym/102361/problem/E Solution 观察到性质若干然后建图跑最大流即可. 我的 ISAP 被卡了,换成 Dinic 却过了. #include <bits/stdc++.h> using namespace std; const int maxn = 200005; const int inf = 1e+9; #define reset(x) memset(x,0,siz

【codeforces 718E】E. Matvey&#39;s Birthday

题目大意&链接: http://codeforces.com/problemset/problem/718/E 给一个长为n(n<=100 000)的只包含‘a’~‘h’8个字符的字符串s.两个位置i,j(i!=j)存在一条边,当且仅当|i-j|==1或s[i]==s[j].求这个无向图的直径,以及直径数量. 题解:  命题1:任意位置之间距离不会大于15. 证明:对于任意两个位置i,j之间,其所经过每种字符不会超过2个(因为相同字符会连边),所以i,j经过节点至多为16,也就意味着边数至多