#P3788. Calculating the Red Portion of a Sliced Watermelon
Calculating the Red Portion of a Sliced Watermelon
Calculating the Red Portion of a Sliced Watermelon
A large watermelon has been specially prepared and then partially sliced. The watermelon can be considered a perfect sphere. Its outer skin (rind) is green with negligible thickness, and its interior flesh is red. When viewed from the top, the watermelon appears as a circle. A slice is made by cutting off a wedge. This wedge (when viewed from above) is a circular sector with the center of the circle as its vertex and a radius equal to the watermelon’s radius.
To describe the problem conveniently, a polar coordinate system is set up on the top view plane with the origin at the center of the circle. The polar axis is directed vertically downward, corresponding to an angle of \(0^\circ\), and angles increase in the counterclockwise direction until \(360^\circ\) is reached. The cut is made across the entire sector from angle \(a^\circ\) to \(b^\circ\). Note that \(a\) and \(b\) can be any real numbers in \([0, 360)\), and the central angle of the removed sector is \(\theta\), which is calculated as follows: \[ \theta = \begin{cases} b - a, & \text{if } b \ge a, \\ 360 - (a - b), & \text{if } b < a. \end{cases} \]
After the slice, when the watermelon is observed from the front, one sees a combination of the green original skin and the red cut surface (exposed flesh). The total visible area remains the same as the projected area of the complete circle \((\pi R^2)\), while the red area corresponds to the area of the cut surface, which is exactly the area of a circular sector with central angle \(\theta\). Therefore, the percentage of the red area in the visible portion of the watermelon is given by:
\(\text{Percentage} = \frac{\theta}{360} \times 100\%\)
Your task is to compute this percentage given the angles \(a\) and \(b\).
inputFormat
The input consists of two real numbers \(a\) and \(b\) (in degrees), separated by a space.
outputFormat
Output a real number representing the percentage of the visible area that is red, formatted to two decimal places.
sample
30 150
33.33