L - Unlucky Bird

一只鸟在铁轨上飞行,看到两列火车从不同方向驶来。尽管它尝试通过碰触火车传递信号让司机停车,但最终火车停了下来,避免了碰撞,而小鸟却未能幸免。计算了火车的速度、制动加速度以及小鸟的速度后,确定了小鸟在牺牲前覆盖的距离。
摘要由CSDN通过智能技术生成

A bird was flying on a train line, singing and passing 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 be on another line. But it realized soon after that both the trains were on the same line!

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

When the trains were d meter way, the drivers realized the abnormal behavior of the strange bird and saw the opposite trains, and both drivers braked hard! They were able to stop the collision, but they managed to stop in front of each other leaving no space. A thousand lives saved, but the bird couldn't save itself!

For simplicity, we denote the train (that was behind the bird) as the left train and the other one as the right train. The left train had velocity v1 m/s (meter per second) and the right train had velocity v2 m/s and they saw each other when they were d meter away. The driver in the left train made a deceleration of a1 m/s2 and the driver in the right train made a deceleration of a2 m/s2. And the trains just avoided the collision. That means they just stopped when their distance was 0 meter. The bird had a constant velocity of v3 m/s. And assume that the bird can turn immediately and can keep its constant velocity. When the trains were d meter 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 its life for the thousand 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 will be greater than 1000. 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 will be ignored.

Sample

#include<bits/stdc++.h>
using namespace std;
using i64 = int64_t;
#define int i64
#define endl '\n'
int n,m,sum,ans,A,B;
/*
*/
void solve()
{
    int t;
    cin >> t;
    for(int i = 1;i <= t;i++)
    {
        double v1, v2, v3, a1, a2;
        cin >> v1 >> v2 >> v3 >> a1 >> a2;
        double ans1 = max(v1 / a1, v2 / a2) * v3;//停止时v = 0,求各车停车花费的最大时间
        double ans2 = v1 * v1 / 2 / a1 + v2 * v2 / 2 / a2;
        // 2as = v1 ^ 2 - v0 ^ 2; 小鸟飞行距离为 s1 + s2;
        cout << "Case "<< i << ": " << std::fixed << std::setprecision(6)  <<  ans2 << " " << ans1 << endl;   
    }
}

signed main()
{
    cin.tie(0) -> sync_with_stdio(false);
    int T = 1;
    //cin >> T;
    while(T--)
    solve();
    return 0;
}
InputcopyOutputcopy
1
0.5 1.0 2 0.25 0.5
Case 1: 1.5000000000 4.0000000000
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值