lightoj 1311 - Unlucky Bird 【物理基础】

一只小鸟在铁轨上飞行,先后遇到两辆相向而行的火车。为了防止事故,小鸟以恒定速度在两车之间穿梭,试图引起司机注意。当火车相距d米时,司机紧急刹车,最终停在了彼此面前,但小鸟牺牲。题目要求计算从d米开始,小鸟飞行的距离。输入包含火车速度、加速度和小鸟速度,输出小鸟的飞行距离。
摘要由CSDN通过智能技术生成
1311 - Unlucky Bird
Time Limit: 1 second(s)Memory Limit: 32 MB

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 in another line. But after a while it realized that 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 was coming from the front side, and after touching the train the bird turned back immediately, and flew until it could touch another 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! But alas! They were able to stop the collision, but they managed to stop in front of each other leaving no distance. And the brave bird was dead in the middle of the trains. Thousand lives saved, but none remembered the bird.

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 a1m/s2 and the driver in the right train made a deceleration of a2 m/s2. And the trains just avoided collision. That means they just stopped when their distance was 0 meter. The bird had constant velocity of v3 m/s. And assume that the bird can turn immediately and can keep its constant velocity. When the trains were dmeter 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 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 Input

Output for Sample Input

1

0.5 1.0 2 0.25 0.5

Case 1: 1.50000000 4.0

 


PROBLEM SETTER: JANE ALAM JAN

题意(简化后的):两辆火车相向而行,相距为d时同时做匀减速运动,正好在距离为0时停止,在这个过程中一只小鸟一直在飞。给定两辆火车的速度v1、 v2和加速度a2、a2,以及小鸟的速度v3,问你距离d 和 小鸟飞过的路程。

没什么说的吧,注意读懂题意。

v*v = 2*a*x。

AC代码:

#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#define INF 0x3f3f3f3f
#define eps 1e-8
#define MAXN 50
#define MAXM 50000000
#define Ri(a) scanf("%d", &a)
#define Rl(a) scanf("%lld", &a)
#define Rf(a) scanf("%lf", &a)
#define Rs(a) scanf("%s", a)
#define Pi(a) printf("%d\n", (a))
#define Pf(a) printf("%lf\n", (a))
#define Pl(a) printf("%lld\n", (a))
#define Ps(a) printf("%s\n", (a))
#define W(a) while(a--)
#define CLR(a, b) memset(a, (b), sizeof(a))
#define MOD 1000000007
#define LL long long
#define lson o<<1, l, mid
#define rson o<<1|1, mid+1, r
#define ll o<<1
#define rr o<<1|1
using namespace std;
int main()
{
    int t, kcase = 1;
    Ri(t);
    W(t)
    {
        double v1, v2, v3, a1, a2;
        Rf(v1); Rf(v2); Rf(v3); Rf(a1); Rf(a2);
        double D = max(v1 / a1, v2 / a2) * v3;
        double x = v1 * v1 / 2 / a1 + v2 * v2 / 2 / a2;
        printf("Case %d: %.7lf %.7lf\n", kcase++, x, D);
    }
    return 0;
}



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值