Quite recently, the City of Barcelona has included trams to its “efficient” public transport. As expected, the result has been a nice set of accidents of outstanding originality and beauty. But diminishing aesthetic reasons, the Mayor of Barcelona has decided to reduce the delay caused by the accidents. After a thorough study the following model has been established.
Every tram must go from an initial point to a final point visiting the intermediate points , …, in this order. For every , let be the section that goes from to . Every such section must be travelled at uniform speed , which is chosen by the driver at . Let be the maximum possible speed of the tram at , and assume that the chosen speed is . Then the probability of crashing in is . When a crash happens, the tram uses an efficient recovery system that lasts only 10 seconds. Afterwards, the tram reaches using an auxiliary (slow but safe) engine, which provides a speed of 5 meters per second and guarantees no more crashes in .
For instance, assume that the section length is 300 meters, and that the current maximum speed is 25 meters per second. If the driver chooses to travel at , the tram will crash for sure. Since this can happen anywhere between and , for the sake of computation we can assume that it will take place exactly in the middle point (after 150 meters). Therefore, on the average the tram will spend 6 seconds to reach the middle point, 10 seconds to recover from the crash, and 30 seconds to reach , for a total of 46 seconds. By contrast, if the tram starts traveling at , with probability it will crash and spend seconds, and with probability it will reach after 20 seconds without any crash. The average time in this case is thus just seconds.
When the tram reaches every , it stops for a few seconds regardless of having crashed in or not; these few seconds (for simplicity, we consider them to be 0) are enough to (almost) repair the tram: the maximum speed reduces by after every crash. In other words, if we call the initial maximum speed , then we have , where is the total number of crashes suffered in , …, .
Write a program to print the optimal average travel time given the initial maximum speed and the length of every section.
Input consists of several cases, each one with (a real number between 5 and 1000), (an integer number between 1 and ), and the length of every section (each one a real number between 100 and 1000).
@par @ @̧tmp=0 @̧tmp=0 @̣tmp@̣tmp by@̣tmp =-@̧tmp=@̣breite @̣leftskip
For every case, print the optimal average travel time with four digits after the decimal point. The input cases have no precision issues.
Input
25 1 900 25 2 900 900 25 2 305.15 980.76 5 1 1000
Output
102.0000 205.0303 150.0000 210.0000