What are your chances of hitting a fly with a tennis
racquet?
To start with, ignore the racquet’s handle. Assume the
racquet is a perfect ring, of outer radius and thickness (so the inner radius of the ring
is ).
The ring is covered with horizontal and vertical strings.
Each string is a cylinder of radius . Each string is a chord of the
ring (a straight line connecting two points of the circle).
There is a gap of length between neighbouring strings. The
strings are symmetric with respect to the center of the racquet
i.e. there is a pair of strings whose centers meet at the
center of the ring.
The fly is a sphere of radius . Assume that the racquet is moving
in a straight line perpendicular to the plane of the ring.
Assume also that the fly’s center is inside the outer radius of
the racquet and is equally likely to be anywhere within that
radius. Any overlap between the fly and the racquet (the ring
or a string) counts as a hit.
Input
One line containing an integer , the number of test cases in the
input file. The next
lines will each contain the numbers , , , and separated by exactly one space.
Also the numbers will have at most 6 digits after the decimal
point.
Output
lines, each of the
form “Case #: ”, where is the number of the test case and
is the probability of
hitting the fly with a piece of the racquet. Answers with a
relative or absolute error of at most will be considered
correct.
Limits
Numbers ,
, , and will be positive and smaller or
equal to . You
can assume that <
, < and < . Furthermore, and the total
number of strings will be at most 2000 (so at most 1000 in each
direction).
Sample Input 1 |
Sample Output 1 |
5
0.25 1.0 0.1 0.01 0.5
0.25 1.0 0.1 0.01 0.9
0.00001 10000 0.00001 0.00001 1000
0.4 10000 0.00001 0.00001 700
1 100 1 1 10
|
Case #1: 1.000000000
Case #2: 0.910015326
Case #3: 0.000000083
Case #4: 0.002371389
Case #5: 0.573972251
|