Solar rocket P64151


Statement
 

pdf   zip

thehtml

At a planet far away, an alien civilization is developing a rocket that works with solar energy. Assume this simplified model: The rocket is a point that moves vertically. Due to gravity, there is a constant downward acceleration of a everywhere. At the rocket location, there are h hours of daytime, followed by h hours of nighttime, followed by h hours of daytime, etc. During the daytime hours, the solar engines of the rocket provide an upward acceleration of b. Will the rocket reach a vertical distance of d ? If so, can you compute the first time to reach that point?

Input

Input consists of several cases, each with a, b, h and d. Assume that a and b are real numbers such that 1 ≤ a < b ≤ 10, that h is an integer number between 1 and 20, that d is an integer number between 1 and 10000, and that all the units used are km and hours.

Output

For every case, print “never” if the rocket will never reach height d. Otherwise, print the minimum time to reach that height, with four digits after the decimal point. The input cases have no precision issues, nor ill-conditioned cases. With the given cases, the answer will never be larger that 200 hours.

Public test cases
  • Input

    1 4 3 10
    1 4 3 1000
    2 5 7 10000
    3.1 5.3 12 2000
    3.1 5.3 12 200
    6.15 9.95 19 1024
    3.12 5.96 19 1481
    

    Output

    2.5820
    41.8100
    183.3596
    never
    13.7570
    25.4604
    59.0880
    
  • Information
    Author
    Salvador Roura
    Language
    English
    Official solutions
    C++
    User solutions
    C++