Under construction

Still being built. Things may change

Where's the Rainbow

Time limit1sMemory limit128 MB

Summary
Given the height of a semicircular rainbow and the viewing angle to its top, compute the distance from the origin to the nearest point of the arc.
Level

Easy3 of 10

Topics
Geometry, Math
Solved
No attempts yet

Problem

After a long day of solving problems you step outside and see a rainbow, and you want to know how far you have to walk to reach the pot of gold at its end.

On the two dimensional plane the rainbow is a semicircle whose center lies on the xx axis. Its highest point has height hh, so its radius is hh, and if the center is (c,0)(c, 0) then the top of the arc is (c,h)(c, h) with c>0c > 0. The two points where the arc meets the xx axis belong to the rainbow.

You stand at the origin. Ignore your height and width and treat yourself as a single point. Looking up from the origin at the top of the rainbow gives an angle of inclination θ\theta.

Given hh and θ\theta, find dd, the distance from you to the closest point of the rainbow.

A person standing at the origin, the semicircular rainbow, the angle of inclination θ and the distance d

Input

The first line contains the number of test cases. Each of the following lines holds one test case as two real numbers separated by a single space. The first value is hh (1≤h≤1051 \le h \le 10^5), the height of the rainbow at its highest point. The second is the angle of inclination θ\theta (0<θ<900 < \theta < 90), measured in degrees. Both numbers consist of decimal digits and at most one decimal point.

Output

For each test case print one line of the form Case x: d, where xx is the case number starting from 1 and dd is the distance from you to the rainbow, rounded to six digits after the decimal point. Always print all six digits, trailing zeros included.

No input sits close enough to a rounding boundary for the sixth digit to be in doubt, so double precision arithmetic produces the same digits as the intended answer.

Examples2

  1. Example 1

    Input
    2
    50.0 45.0
    100.0 75.0
    
    Expected output
    Case 1: 0.000000
    Case 2: 73.205081
    
  2. Example 2

    Input
    3
    1 45
    1 30
    1 60
    
    Expected output
    Case 1: 0.000000
    Case 2: 0.732051
    Case 3: 0.422650