In-circles Again

Time limit1sMemory limit128 MB

Summary
Each circle tangent to two sides of a triangle and its incircle has radius r divided by the sine of a half-angle; recover the three angles from r, r1, r2, r3 and compute the area.
Level

Medium4 of 10

Topics
Geometry, Math, Implementation, Brute force
Solved
No attempts yet

Problem

The figure below shows triangle ABCABC together with its in-circle (the circle that touches all three sides of the triangle from the inside). The radius of this in-circle is rr. Three more circles are drawn; each of them touches two sides of the triangle and the in-circle of ABCABC. The radii of these three circles are r1r_1, r2r_2, and r3r_3.

Given the values of rr, r1r_1, r2r_2, and r3r_3, find the area of triangle ABCABC.

Input

The input consists of up to 10001000 datasets. Each dataset holds four positive floating-point numbers rr, r1r_1, r2r_2, and r3r_3 in that order. The input is terminated by a dataset of four negative numbers.

The values are separated by whitespace (including newlines), so a single dataset may span several physical lines. Read the values as whitespace-separated tokens rather than line by line.

Output

For each dataset print one line in the format Case k: A, where kk is the 11-based dataset number and AA is the area of triangle ABCABC shown to two digits after the decimal point. You may assume that a triangle ABCABC can always be constructed from the given rr, r1r_1, r2r_2, r3r_3. If needed you may take π=3.141592653589793\pi = 3.141592653589793 and use double-precision floating-point numbers. No input is given for which small precision errors would change the printed output. Refer to the sample output for the exact format.

Examples5

  1. Example 1

    Input
    49.1958415692 5.3025839959 20.7869367050 31.8019699761
    186.6830516757 71.9474500429 84.8796672233
    37.6219288070
    -1 -1 -1 -1
    
    Expected output
    Case 1: 18237.14
    Case 2: 195777.32
    
  2. Example 2

    Input
    3.0 1.0 1.0 1.0
    -1 -1 -1 -1
    
    Expected output
    Case 1: 46.77
    
  3. Example 3

    Input
    10.0 1.7157287525380995 4.464626921716896 4.464626921716896
    -1 -1 -1 -1
    
    Expected output
    Case 1: 582.84
    
  4. Example 4

    Input
    25.0 3.311858285794856 10.146462930133183 14.71976766202159
    -1 -1 -1 -1
    
    Expected output
    Case 1: 4197.29
    
  5. Example 5

    Input
    7.5 2.032425405901083 2.5 3.043938879039955
    12.0 0.8615612366938903 5.883487158788427 8.449058292502167
    -1 -1 -1 -1
    
    Expected output
    Case 1: 298.39
    Case 2: 1295.44