Circles get lots of attention when studying geometry, working as excellent
models for various concepts in trigonometry, physics, and many other fields. We
often learn a good deal about circles in school, such as a given circle having
radius r will have a perimeter of P = 2 * π * r and an area of A = π * r ^ 2.
However, maybe we focus a bit too much on perfect circles and should also be looking
at some more general cases.
Just as squares belong to the broader category of shapes known as rectangles, circles belong to the broader category of shapes called ellipses. Intuitively we can understand ellipses as circles that have been "squished" or "stretched" linearly along some axis.
The geometric definition of an ellipse is more exact. Imagine two points
F1 and F2 which will be known as focus points or foci. Then let's imagine
we are standing at some third point P. We could calculate the distances
between P and F0, and also between P and F1, and then call the sum
of those differences D. Choosing some value for D0 and then marking all the
possible points for P where D = D0 will trace out the edge of an ellipse.
The set of all points satisfying a condition around foci is called a locus.
The distances from each foci to each point on the edge of the ellipse always sum to a constant value.
Notice that if the two foci were two occupy the same point in space, then shape traced out would result in a circle!
It should be clear that the centerpoint of the ellipse falls at the centerpoint
between the two foci. The longest possible distance from this centerpoint to the
ellipse's edge is known as the semi-major axis a, whereas the shortest possible
distance from this centerpoint to the ellipse's edge is known as the semi-minor
axis b. The area of an ellipse is given by the equation A = π * a * b, which
mirrors the equation for the area of a circle when a = b.
An ellipse's semi-major axis a and semi-minor axis b.
Imagine an ellipse with two foci having (x, y) coordinates of (0, 0) and (x0, 0).
You will be asked to return the area of the ellipse formed by the two foci
and a given total sum distance D0.
Input Data
First line will be Q, the quantity of testcases.
Q lines will then follow, each with two space-separated values x0 D0.
Answer
Should consist of Q space-separated values, corresponding to the areas of each
described ellipse.
Error should be less than 1e-6.
Example
input data:
3
0 2
1 2
7 10
answer:
3.141593 2.720699 56.088648