BRI - Bridge

no tags 

Find a place to build a bridge over the river, so as to minimize total cost of the route between two cities A and B, located on opposite sides of the river.

Input

There is a single positive integer T on the first line of input (equal to about 100000). It stands for the number of test cases to follow. Each test case is exactly one line, containing six integers a, b, c, h, s1 and s2 (0 < a, b, c, h, s1, s2 < 100), separated by spaces. a - the distance from city A to the river (the length of segment AE in the figure), b - the distance from city B to the river (the length of segment FG in the figure), c - the distance between A and B along the axis parallel to the river (the length of segment BF in the figure) and h - the width of the river (EG in the figure). s1 and s2 are the costs of unit of road and bridge respectively.

Output

For each test case your program should write a single number to the standard output, equal to the minimal total cost of the route between A and B, accurate up to two digits after the decimal dot.

Example

Input:
1
1 1 1 1 1 1

Output:
3.16

hide comments
(Tjandra Satria Gunawan)(曾毅昆): 2012-09-11 16:06:05

@mini:
Input:
2
1 1 3 1 2 1
1 1 3 1 1 2
Output:
6.71
5.43

mini: 2012-09-11 15:29:21

could someone with AC please post solution for
2
1 1 3 1 2 1
1 1 3 1 1 2

well i am lagging: 2012-04-02 11:25:15

position of C,D which we have to find is an integer right?

ruchin: 2010-05-11 09:50:39

@Chinmay:-well i think taking this as refraction of light will solve it..and on my pc the results are perfectly fine..but here i m getting TLE...dont know how to solve the equation for sine of theta....so actually i m increasing the value of theta by 0.001 until the theta doesn't satisfy the equation...i know it's bad algo but i dont have any other choice...if u find anything else on this then please tell me..i m stuck on this...

Last edit: 2010-05-11 09:55:35
Reborn In Fire...: 2010-04-24 20:09:00

can ne1 suggest some page or give a hint??

[Trichromatic] XilinX: 2009-11-10 07:52:49

1e-9 is enough :)

Tony Beta Lambda: 2009-11-10 04:59:36

Epsilon is quite small. 1e-12 is okay.


Added by:Ruslan Sennov
Date:2009-09-27
Time limit:1.237s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ERL NODEJS PERL6 VB.NET
Resource:Based on HSPL09BRI