ACC - A Complex Cone

A cone with radius of base 'r' and height 'h', is stretched to the left and right by length 'a' and 'b' respectively such that height of the stretched cones equal the height of the original cone and apexes of all the three cones are colinear.

complex cone

Write a program to calculate the volume of the union of the two stretched cones (colored blue in image).

Input

The first line of input is the number of test cases T. (1 ≤ T ≤ 100)

For each test case, there is a single line containing 4 integers 'r', 'h', 'a' and 'b' respectively. (0 < r, h, a, b ≤ 10)

Output

Output a single line for each test case, containing the volume with 1 decimal place only. Answer should be correct to 1 decimal place without rounding off.

Example

Input:
2
1 1 1 1
10 10 10 10

Output:
1.4
1491.6

Added by:yogi
Date:2018-11-10
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All
Resource:Own problem, Origin

hide comments
2021-10-04 23:09:27 Tomasz Rzepecki
Using <spoiler> resulted in NZEC. Thankfully, the maximum data is so small that I could just include a table of answers in the source. Frankly, it should not be that small, but oh well.

Last edit: 2021-10-05 10:51:38
2020-04-08 18:58:04
Can someone help me with the formula for the intersection, I am completely clueless
2019-01-08 14:55:40
Does this problem require knowledge of integration?
2019-01-02 20:17:20 Cool Licznik
Nice problem - it was fun to solve. Thanks for posting. If anyone needs exact value for first example it is 4/9+pi/3.
2018-12-15 07:02:08 Yogendra Kumar
Thanks @cool_licznik for pointing it out! My sincere apologies to all for the trouble it might have caused! I just corrected the values in Example Output in the problem description.
2018-12-05 14:03:16 Cool Licznik
I've calculated it by three different methods, confirmed with visualizations and I'm convinced that the results should be about 21% higher (1491.642 for second case). Visualization:
https://www.geogebra.org/m/mkaepdfx
Red polyline shows intersection (hardcoded values not to spoil the fun for others).

Last edit: 2018-12-05 19:37:56
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.