CPC '21 Contest 1 P3 - AQT and Circles

View as PDF

Submit solution


Points: 10 (partial)
Time limit: 2.0s
Python 4.0s
Memory limit: 256M

Author:
Problem types

AQT is studying circles and he has encountered the following problem. Two circles C1 and C2 have their centres located at (0,0) on a coordinate plane. Circle C1 and C2 have radii R1 and R2 (R1R2), respectively. AQT decides to add another circle C3 with radius R3 (R3<R2) and a centre that is located at (x,y), where x and y are real numbers. The location of circle C3 is random but it follows the condition that it is completely inside circle C2. Formally, x2+y2<(R2R3)2. A position of circle C3 is called valid if the circumference of circle C3 has 0 intersection points with the circumference of circle C1. AQT wants to know the probability that the position of circle C3 is valid. AQT is given T of these problems. Can you help AQT solve all of them?

Constraints

In all subtasks,

1T2105

1R1R2103

1R3<R2

It is guaranteed that R1, R2, and R3 are integers.

Subtask 1 [10%]

R1=R2

Subtask 2 [15%]

0R2R12

R3<R1

Subtask 3 [75%]

No additional constraints.

Input Specification

The first line contains T, the number of problems you need to help AQT solve.

The next T lines each contain the radii of the three circles: R1, R2, and R3.

Output Specification

Output T lines. In the i-th line, output the answer to the i-th problem. Your answer will be considered correct if it differs from the correct answer by at most 103.

Sample Input

Copy
2
2 3 1
5 10 2

Sample Output

Copy
0.25
0.375

Explanation

For the first test case, circle C1 and C2 are represented by the blue circle and the red circle, respectively. The green circles represent possible valid positions for circle C3.

This region represents the set of all possible centres for circle C3 and has an area of 4π
This region represents the set of all valid centres for circle C3 and has an area of π
The probability is π4π=0.25

Comments

There are no comments at the moment.