Lightoj 1311-unlucky Bird (math AH)

Source: Internet
Author: User

Title Link: http://lightoj.com/volume_showproblem.php?problem=1311



A bird is flying on a train line, singing and passing the lazy times. After a while it saw a train coming from its behind, so, it speeded up a bit, but remained calm. After a while it saw another train coming towards it from the front side. The bird remained calm thinking that the train coming towards him would is in another line. But after a while it realized this both the trains were on the same line!

So, the stupid brave Bird made a plan to stop the accident. So it flew towards the train which is coming from the front side, and after touching the train the bird turned back immed Iately, and flew until it could touch another train. And after the it turned back, and continued this procedure. The birds ' intention is to signal the drivers such that they could stop the train.

When the trains were D Meter, the drivers realized the abnormal behavior of the strange bird, and saw the OPP Osite trains, and both drivers braked hard! But alas! They were able to stop the collision, but they managed to stop in front for each other leaving no distance. And the brave bird is dead in the middle of the trains. Thousand lives saved, but none remembered the bird.

For simplicity we denote the train (that is behind the bird) as the left train and the other one as the right train. The left train had velocityv1m/s(meter per second) and the right train had velocityv2 m/sAnd they saw each other when they wereDMeter away. The driver in the left train made a deceleration ofA1 M/s2And the driver in the right train made a deceleration ofA2 M/s2. And the trains just avoided collision. That means they just stopped then their distance was0Meter. The bird had constant velocity ofv3 m/s. And assume the bird can turn immediately and can keep its constant velocity. When the trains wereDMeter away, the bird was somewhere between the trains. Your task is to find the distance covered by the brave bird (from this moment) in meters before sacrificing it life for t Housand lives.

Input

Input starts with an integer T (≤100), denoting the number of test cases.

Each case starts with a line containing five positive real numbers: v1 v2 v3 A1 A2 (V1 < V3, v2 < v3). No real number would be greater than . And no number contains more than three digits after the decimal point.

Output

For each case, print the case number, D and the distance covered by the bird. Errors less than 10-6 'll be ignored.

Sample Input Output for Sample Input

1

0.5 1.0 2) 0.25 0.5

Case 1:1.5 4.0


The code is as follows:

#include <cstdio> #include <cmath> #include <algorithm>using namespace Std;int main () {    int t;    Double V1, V2, v3, a1, A2;    int cas = 0;    scanf ("%d", &t);    while (t--)    {        scanf ("%lf%lf%lf%lf%lf", &v1,&v2,&v3,&a1,&a2);        Double T1 = v1/a1;        Double t2 = v2/a2;        Double TT = max (t1, T2);        Double S1 = v1*v1/(2*A1);        Double s2 = v2*v2/(2*A2);        printf ("Case%d:%lf%lf\n", ++CAS,S1+S2,V3*TT);    }    return 0;}


Lightoj 1311-unlucky Bird (math AH)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.