Hide

Problem C
Circular Painting

/problems/rupc19.circularpainting/file/statement/en/img-0001.jpg
The sign outside the university.
It has been decided that the sign outside the university is too small, and a new and much bigger sign should be constructed. A huge wooden panel of sufficiently large dimensions has been built, and now you’ve been tasked with painting the university’s logo on this panel.

The logo is composed of disjoint circular sectors around a complete circle, and you’ve been given instructions for how to paint the logo in terms of these sectors. Starting from a horizontal angle to the right, and proceeding in counterclockwise direction, each part of the logo is painted as a circular sector of a given angle, inner radius, and outer radius.

\includegraphics[width=0.30\textwidth ]{logo}
Figure 1: Illustration of Sample Input 3.

The only thing you’re missing is the paint. In order to estimate the amount of paint needed, you decide to calculate the total area that the circular sectors will cover on the sign.

Input

The input consists of:

  • One line with one integer $n$ ($1 \le n \le 360$), the number of circular sectors.

  • $n$ lines, the $i$th of which contains three integers $d$, $r_1$ and $r_2$ ($1\le d\le 360$, $0 \le r_1 \le r_2 \le 1\, 000$), the angle in degrees, inner radius in centimetres, and outer radius in centimetres of the $i$th circular sector. $r_1=r_2$ is used to represent an empty circular sector of the given angle.

The sum over angles of all circular sectors equals $360$.

Output

Output the total area of the circular sectors in square centimetres.

Your answer should have an absolute or relative error of at most $10^{-3}$.

Sample Input 1 Sample Output 1
2
180 0 10
180 5 20
746.128255228
Sample Input 2 Sample Output 2
4
90 0 0
45 1 20
180 0 0
45 1 20
313.373867196
Sample Input 3 Sample Output 3
20
33 10 30
33 10 40
9 10 20
25 10 30
10 10 25
60 10 40
10 10 30
15 10 20
10 0 0
3 10 34
22 10 40
10 10 30
10 10 25
10 0 0
35 10 40
10 10 35
10 10 30
20 10 40
5 10 20
20 10 30
3272.64942712

Please log in to submit a solution to this problem

Log in