#P3788. 幽幽子吃西瓜
幽幽子吃西瓜
Description
Youmu put great effort into preparing a big watermelon for Yuyuko, even getting into a fight with the rabbit Reisen. Now, with nothing else to do, Youmu squats to the side and watches Yuyuko eat the watermelon. The watermelon can be regarded as a perfect sphere: the rind is green, the flesh is red, and the rind’s thickness can be considered 0. Youmu is looking at this watermelon head-on (front view). Because Yuyuko is such a foodie, the moment Youmu looks away, the sword behind her goes missing, and a piece of the watermelon has been cut off. While Yuyuko is cutting, the blade’s plane is always vertical to the tabletop, and the piece she cuts off appears in the top view exactly as a sector whose vertex is at the watermelon’s center and whose radius equals the watermelon’s radius. As shown in the figure, this is one valid situation.
Top view:

Front view:

Looking at the red-and-green watermelon, Youmu suddenly wonders: what percentage of the visible area of the watermelon is the red flesh? However, she knows nothing about geometry. She wants to ask Yuyuko, but Yuyuko is busy devouring the cut-off piece and ignores her. So Youmu wants you to help solve this problem.
To make the problem easier to describe, we set up a plane polar coordinate system on the top view. The pole is at the exact center of the circular (sector) top view, and the polar axis points straight downward. The polar angle corresponding to the axis is 0 degrees. Angles increase counterclockwise until a full rotation returns to the polar axis. Therefore, the angle range is . Yuyuko will cut off the entire sector from to .
Input Format
The first line contains an integer T, the number of test cases.
Each of the next T lines contains two integers a and b, representing the starting and ending angles of the cut range. If , then the cut angle range is .
Output Format
Output T lines. Each line contains a real number followed by a percent sign "%", representing the percentage of the red watermelon flesh area in the front view (parallel projection) of the watermelon after the cut. In this problem, Youmu’s viewing direction is parallel to the polar axis in the top view, and the ray of the polar axis points toward Youmu.
Round the real number to one digit after the decimal point. Your answer is judged correct if and only if it matches the standard answer exactly.
2
90 270
315 45
0.0%
70.7%
Hint
Sample explanation:
In the first sample, the cut is exactly on the back side. From Youmu’s point of view, it looks no different from an uncut watermelon, so the output is 0%.
In the second sample, the cut is from to . After calculation, the answer is , whose decimal is 0.707, i.e., 70.7%.
There are 10 test points in total.
For test point 1, .
For test point 2, , .
For test points 3–4, , .
For all test points, , .
.
Author: orangebird.
Translated by ChatGPT 5
京公网安备 11011102002149号