兩軍交鋒
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 8466 Accepted Submission(s): 5223
Problem Description
話說遼軍與MCA相峙多年,終於在一個秋日的早晨爆發了一次大規模的衝突.情況是這樣子的,當天上午,由耶律-Pacision領軍的遼軍忽然帶領數萬人馬浩浩蕩蕩向MCA山殺來,而這時候駐紮在MCA防守前線的是久經沙場的老將紀哥.紀哥得知這個消息,立刻召集手下精英,前往阻擊遼軍.現已知遼軍前進速度 U 米/秒 ,紀哥 速度 V 米 /秒 ,兩軍一開始相距L米,戰地記者從兩軍剛開始進軍就立刻開始以 W 米/秒的速度馬不停蹄地往返於兩軍之間作第一時間的報道,即一到達一方,立刻返回前往另一方.問,當兩軍交鋒之時,戰地記者總共走的路程.
Input
首先輸入一個t,表示有t組數據,跟着t行:
每行有四個實數 u ,v , w , l 分別表示遼軍速度,紀哥速度,記者速度,以及起始的距離.
Output
輸出一行實數表示總的路程.精確到小數點後3位.
Sample Input
1
10 20 30 100
Sample Output
100.000
code:
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
int main()
{
int N;
scanf("%d",&N);
while (N--)
{
double x, y,z,l;
scanf("%lf%lf%lf%lf",&x,&y,&z,&l);
double t;
t = 1.0*l/(x+y);
double ll = t*z;
printf ("%.3lf\n",ll);
}
}