El campanar de la Torrassa is 75 years old! P17681


Statement
 

pdf   zip

thehtml

[r] El Campanar de la Torrassa is the mythical bell tower of a church in the district of La Torrassa in the city of L’Hospitalet de Llobregat. This tower (which celebrates its 75th birthday precisely this year!) is near the author’s home, where some nice (but not wild!) parties with the UPC contestants took place. During one of those parties, Masao heard the sound of the bells, and immediately his powerful brain started to wander and wonder:
“Let’s suppose that a clock has an hour hand 3 units long, a minute hand 4 units long, and a second hand 5 units long. The hour hand moves once every hour, the minute hand moves once every minute, and the second hand moves once every second. Therefore, exactly every second, the triangle defined by the ends of the hands changes its area.
For instance, to the right you can see the positions of the hands at 00:15:25. Note that the hour hand is vertical and the minute hand is horizontal.

[r]

Which is the maximum area between two given times?”

Input

Input consists of several cases, each with h1:m1:s1 and h2:m2:s2. You can assume 0 ≤ h1 < 12, 0 ≤ m1 < 60, 0 ≤ s1 < 60, as well as 0 ≤ h2 < 12, 0 ≤ m2 < 60, 0 ≤ s2 < 60. The time h1:m1:s1 is strictly smaller than h2:m2:s2.

Output

For every case, print with three digits after the decimal point the largest area from h1:m1:s1 to h2:m2:s2, both times included. This problem has no precision issues, as long as you take special care of times like 01:05:35.

Hint

Remember that the area of a triangle with sides of length a, b and c is √s(sa)(sb)(sc) , where s = (a+b+c)/2 is the semiperimeter of the triangle.

Public test cases
  • Input

    00:00:00    00:00:01
    11:59:58    11:59:59
    03:59:08    03:59:24
    03:59:08    03:59:25
    00:00:00    11:59:59
    

    Output

    0.261
    0.922
    7.142
    8.395
    20.485
    
  • Information
    Author
    Jordi Petit
    Language
    English
    Official solutions
    C++
    User solutions
    C++