Title Link: http://acm.timus.ru/problem.aspx?space=1&num=1885
1885. Passenger Comforttime limit:1.0 Second
Memory limit:64 MB
Marketing managers of the company Oceanic Airlines started a new advertising campaign. Its aim is to emphasize the comfort of the passengers on board. However, when the board of directors watched the first commercial shot for the campaign, some questions appeared. The commercial ended with the catchy slogan "Oceanic Airlines. Blocked ears. Choose one of the. But the chief executive remembered quite, well, his ears had suffered during he last business trips to Bali with oceanic Airlines ... According to the instructions, the airplane must climb to an altitude of
hmeters during the first
TSeconds of the flight and keep that altitude during the whole flight. The climbing rate must isn't being greater than
vMeters per second. The plane must not descend before the planned altitude is attained. The marketing managers wanted to know if their advertising is truthful. They found out this ears were blocked only when a plane is ascending at a rate of more than
xMeters per second. Help the managers calculate the minimum and maximum amount of time during which passengers could have their ears blocked if The pilot adheres to the instructions. Assume that the plane can change it speed instantly. Inputthe only line contains the integers
h,
T,
v, and
x(5 000≤
h≤12 000; 50≤
T≤1 200; 1≤
x<
v≤100;
h≤
T·
v). Outputoutput-numbers, which is the minimum and maximum numbers of seconds during which passengers may have their Ears blocked. The absolute or relative error of each number should not exceed 10? 6. Sample
input |
Output |
10000 500 50 10 |
125.0 500.0
|
The code is as follows:
#include <cstdio> #include <cstring> #include <algorithm>using namespace Std;int main () { int h, T, V, x; Double Minn, Maxx; while (~SCANF ("%d%d%d%d", &h,&t,&v,&x)) { int tt = T*X; if (TT >= h) { minn = 0; Maxx = h/(x*1.0); } else { minn = (h-x*t*1.0)/(v-x); Maxx = t; } printf ("%lf%lf\n", Minn,maxx); } return 0;}
URAL 1885. Passenger Comfort (math AH)