Solar rocket P64151


Statement
 

pdf   zip

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 aa everywhere. At the rocket location, there are hh hours of daytime, followed by hh hours of nighttime, followed by hh hours of daytime, etc. During the daytime hours, the solar engines of the rocket provide an upward acceleration of bb. Will the rocket reach a vertical distance of dd\,? If so, can you compute the first time to reach that point?

Input

Input consists of several cases, each with aa, bb, hh and dd. Assume that aa and bb are real numbers such that 1a<b101 \le a < b \le 10, that hh is an integer number between 1 and 20, that dd 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 dd. 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++