Sun Bathing

Time limit1sMemory limit128 MB

Summary
Given a rectangular body, a circular parasol, and a sun angle range, report the percentage of the body lit by the sun at some moment.
Level

Medium7 of 10

Topics
Geometry, Implementation, Math
Solved
No attempts yet

Problem

Lying in the sand is the favorite beach activity for many people. Because prolonged sun exposure causes painful sunburns, many sunbathers lie under a parasol to shield themselves from the sun's rays. If you know the time window during which you will lie on the beach, where should you place the parasol to protect as much of your body as possible?

Here we answer a slightly easier question. Given the positions of your body and the parasol, compute what percentage of your body is exposed to the sun for at least part of the time.

For simplicity, model your body as a rectangle of size w×hw \times h centimeters. Treat the beach as a two-dimensional plane with the origin at the center of your body. The side of length hh runs along the feet-to-head direction, and the side of length ww runs across your body. The parasol is a circle of radius rr, mounted horizontally at height dd above your body, with its center also above the origin.

You sunbathe from the moment the sun makes an angle α1\alpha_1 with the beach to the moment it makes an angle α2\alpha_2, where 1∘≤α1<α2≤179∘1^\circ \le \alpha_1 < \alpha_2 \le 179^\circ. Assume the sun is a single point infinitely far away and travels in a straight line from your feet to your head (not from one arm to the other).

Input

The first line contains an integer K≥1K \ge 1, the number of data sets. Each of the following KK lines describes one data set and contains, in this order, the real numbers ww, hh, rr, dd, α1\alpha_1, α2\alpha_2 (the two angles are given in degrees). The sun moves from your feet to your head, i.e. parallel to the side of length hh, and never parallel to the side of length ww.

Output

For each data set, first print a line Data Set x:, where xx is the data set number starting from 11. On the next line, print the percentage of your body that is exposed to the sun at some moment during the interval, rounded to exactly two decimal places and followed by a percent sign (for example, 0.00%).

Examples3

  1. Example 1

    Input
    2
    0.5 1.8 5.0 0.2 70.0 120.0
    0.5 2.0 0.75 1.0 45.0 90.0
    
    Expected output
    Data Set 1:
    0.00%
    Data Set 2:
    76.41%
    
  2. Example 2

    Input
    1
    1.0 1.0 10.0 0.5 30.0 150.0
    
    Expected output
    Data Set 1:
    0.00%
    
  3. Example 3

    Input
    1
    1.0 1.0 0.3 2.0 10.0 170.0
    
    Expected output
    Data Set 1:
    100.00%