杭电ACM2548题

这里写图片描述

这题我刚开始看的时候想的特别复杂,考虑到了分开计算每一次的距离,但最后发现,只要算出两军相遇所需的总时间就可以算出记者走过的距离了。

#include<stdio.h>
int main()
{
    int t;
    double u,v,w,l,x;
    scanf("%d",&t);
    while(t--)
    {
        scanf("%lf%lf%lf%lf",&u,&v,&w,&l);
        x=l/(u+v)*w;
        printf("%.3lf\n",x);
    }
    return 0;
}   

猜你喜欢

转载自blog.csdn.net/qq_43104182/article/details/82629069