Limits 1s, 512 MB

Arav is a curious young boy. He is learning to draw circles. He only got one color but a lot of brushes for his birthday, and he is going to use them to draw circles.

First he will find a huge piece of circular shaped paper. Imagine the center of this paper is at (0, 0).

Next he will pick a brush of his choice. There are a lot of brushes and each one gives a specific width, say D. Now he will make a stroke with the brush R distance away from the center. The stroke will look like an arc in a circle.

After he has finished the drawing, can you help his parents by analyzing what is the total area painted?

Below is the drawing of the sample input-output.

The state without coloring:

The state after coloring:

In short, you will have to find the green area.


The first line of the input is the number of test cases, there will be at most 10 test cases.

Each test cases starts with one number, the number of strokes N (1 ≤ N ≤ 10000) Arav is going to make.

The next N lines each contain four integers, the width of the brush D (1 ≤ D ≤ 100), the distance from center R (0 ≤ R ≤ 10000), the start angle X and end angle Y of the stroke (0 ≤ X < Y < 360). It means he makes a stroke of brush from angle X to angle Y.


For each case write the area in a separate line. The value must be within 0.00001 of the actual solution.


2 5 60 120
2 6 45 90

Be careful with precision.


Login to submit.


30% Solution Ratio
Tahmid690Earliest, May '21
mdshadeshFastest, 0.0s
mdshadeshLightest, 13 kB
Tahmid690Shortest, 1274B
Toph uses cookies. By continuing you agree to our Cookie Policy.