10693-traffic Volume
Time limit:3.000 seconds
Http://uva.onlinejudge.org/index.php? Option=com_onlinejudge&itemid=8&category=467&page=show_problem&problem=16 34
In the "picture below" (or above depending on HTML response:)) You can have a street. It has infinite number of cars on it. The distance between any two consecutive cars are D , length of each car is L and the Velo City is v . The volume of cars through a road means the number of cars passing through a road in a specific amount of. When the ' velocity is constant, D must being minimum for the volume of cars passing through the road to be MA Ximal. In our model, when the velocity of "all" is v then the minimum possible value of D is v/(2f) (the "more" car velocity the more distance your need to bring down your velocity to zero). Here, the F is the deceleration due to break.
Keeping this model in mind and given the value of L and F your job are to find the value of v fo R which the volume of traffic through the road is maximal.
Input
The input file contains several lines of input. Each line of input contains two integers L (0<l<=100) and F (0<f<=10000). The unit's L is meter and the unit of an F is meter/second. The input is terminated by a single line whose value of L and F are zero.
Output
For each line of input except the last one produce one line of output. Each line contains two floating-point number v. and volume separated by a. Here v are the velocity for which traffic the ' is Maximal ' and volume is the maximum number of vehicles (O F Course it is a fraction) passing through the road in a hour. These two floating points should have eight after the decimal. Errors less than 1e-5 would be ignored.
Sample input Output for sample input
First of all to make each vehicle through a point of the least time, that is (l+v*v/2f)/v=l/v+v/2f the least, so when the V=sqrt (2FL) to meet the requirements.
Complete code:
/*0.009s*/
#include <cstdio>
#include <cmath>
int main (void)
{
int l, F;
while (scanf ("%d%d", &l, &f), L)
{
F <<= 1;
printf ("%f%f\n", sqrt (L * f), 1800 * sqrt (double) f/l);
return 0;
}
See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/Programming/sjjg/