Թաքցված խնդիր
|Այս խնդիրը թաքցված է խմբագրական խրհրդի անդամի կողմից քանի որ կամ այն ոչ ճիշտ լեզվով է գրված,|կամ թեստային տվյալներն են սխալ, կամ խնդրի ձևակերպումը պարզ չէ։|

ACM_0067 - VON NEUMANNS FLY

   The following problem was posed to John von Neumann:

   Two bicyclists, A and B, start riding toward each other at the same time from places that are 250 miles apart, A traveling at 10 miles per hour, and B at 15 miles per hour. At the same time, a fly leaves the front wheel of A’s bicycle, and flies toward B’s bicycle at 20 miles per hour. As soon as he touches the front wheel of B’s bicycle, he turns around and flies back. As the bicycles approach each other, he continues flying back and forth, touching each front wheel in turn, until, alas, he is crushed between them. Since the fly travels faster than either cyclist, he makes an infinite number of trips, yet travels a finite distance (the infinite series converges). How far did the fly travel?

   Von Neumann immediately summed the infinite series (in his head!), and arrived at the correct answer: 200 miles.

   You are to write a program that solves a more general version of that problem, with varying initial distances and speeds.

Input

   The first line of input contains a single integer P , (1 P 1000), which is the number of data sets that follow. Each data set should be processed identically and independently.

   Each data set consists of a single line containing five values: an integer N (the data set number), and four floating-point values: D (the initial distance between the bicycles, 10 D 1000), A (cyclist A’s speed in miles per hour, 1 A 30), B (cyclist B’s speed in miles per hour, 1 B 30), and F (the fly’s speed in miles per hour, A B < F 50).

Output

   For each data set there is one line of output. It contains the data set number followed by a single space, followed by the number of miles traveled by the fly, (the sum of the infinite series described by the input values), accurate to two decimal places.

Examples

stdin

stdout

1

5

1 250 10 15 20

2 10.7 3.5 4.7 5.5

3 523.7 15.3 20.7 33.3

4 1000 30 30 50

5 500 15 15 25

1  200.00

2 7.18

3  484.42

4  833.33

5  416.67


Ավելացրեց.Հրանտ Հովհաննիսյան
Ամսաթիվ.2014-01-05
Ժամանակի սահմանափակումը.1s
Ծրագրի տեքստի սահմանափակումը.50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Լեզուներ.Բոլորը բացի ASM32 ASM64 GAWK CLPS CLOJURE D ERL FSHARP FORTRAN GOSU HASK ICON ICK NEM NIM OBJC-CLANG PICO PIKE PYPY PYPY3 PY_NBC RUST SCM guile CHICKEN SED TCL WHITESPACE
Աղբյուրը.NA Greater New York 2013.B

© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.