• LightOJ


    Time Limit: 1000MS   Memory Limit: 32768KB   64bit IO Format: %lld & %llu

    Status

    Description

    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 v1m/s (meter per second) and the right train had velocity v2m/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 a2m/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 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 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

    1

    0.5 1.0 2 0.25 0.5

    Sample Output

    Case 1: 1.50000000 4.0

    Source

    Problem Setter: Jane Alam Jan

    Status

    题目真长 ;

    #include <cstdio>
    int main()
    {
        int t; int Q=1;
        scanf("%d", &t);
        while(t--)
        {
            double v1, v2, v3, a1, a2;
            scanf("%lf%lf%lf%lf%lf", &v1, &v2, &v3, &a1, &a2);
            double     t1=v1 / a1;
            
            double    t2=v2 / a2;
            double    t=t1;
            if(t1 < t2)
                t= t2;
            //double d=0.5*a1*t*t+0.5*a2*t*t;   //损失精度 ;//    double d=v1*v1/2.0/a1+v2*v2/2.0/a2;
            printf("Case %d: %.6lf %.6lf
    ", Q++, d, v3*t);
        }
        return 0;    
    }  

     

     

  • 相关阅读:
    多元化时代敏捷软件开发的崛起与传统软件工程的延续
    敏捷软件开发与传统软件工程概述比较
    结构化方法和面向对象方法的比较
    sql server 的Maintenance Plans(维护计划)详解
    sql server 如何查询出数据库作业所有者的信息并完成批量替换
    sql server 运维时CPU,内存,操作系统等信息查询(用sql语句)
    sql server 数据导出(入)方法总结
    sql server 转置 和实现随机分配和一串代码的含义拼在一行
    python 之路初(一):pycharm 安装 和 环境配置 和 中文乱码问题
    Qt5.9.6 vs2015 SQlite 数据库增删改查
  • 原文地址:https://www.cnblogs.com/soTired/p/5334035.html
Copyright © 2020-2023  润新知