ENG  RUSTimus Online Judge
Online Judge
Online contests
About Online Judge
Frequently asked questions
Site news
Problem set
Submit solution
Judge status
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests

2090. Crossroads of Destiny

Time limit: 1.0 second
Memory limit: 64 MB
Winter in Yekaterinburg is the longest time of the year. And everyone spends long winter evenings in his own way. A few days ago, Sergey found Her on the Internet. She is the girl of his dreams! Today he has invited Her on a date at a small cozy cafe on the crossroads of Marx street and Engels street.
Now Sergey goes to the cafe and he seems to be late. Sergey goes along Marx street, crosses it through a crosswalk, reaches the crossroads with Engels street, crosses it at traffic light and enters the cafe. There is no one inside — She has already gone. However, Sergey thinks not about catching up with her, but whether it was necessary to cross Marx street through the crosswalk. After all, he could reach the crossroads and cross both streets at the traffic light. And who knows, maybe in this case he would not have lost time in waiting for the green traffic light signal and could come in time. Which of these options is faster depends entirely on what point in time the right signal will light. To predict it in advance is impossible, but it is possible to estimate the probability.
Sergey always walks with a constant speed v and strictly follows the traffic rules. So he starts to cross a street at the traffic light only when there is the green signal for him, but not yellow and especially not red. Starting to cross a street, Sergey do it with the same constant speed and without stops, regardless of the traffic light color change. The traffic light at the crossroads of Marx street and Engels street works as follows. For t1 seconds, there is a green signal for pedestrians crossing Engels street, and red signal for crossing Marx street. Then for t2 seconds there is a yellow signal for crossing Engels street and red signal for crossing Marx street. Then for t3 seconds there is a green signal for crossing Marx street and red signal for crossing Engels street. Then for t4 seconds there is a yellow signal for crossing Marx street and red signal for crossing Engels street. Then everything is repeated.


The first line contains an integer v that is the speed of Sergey (1 ≤ v ≤ 106). The second line contains integers d, w1 and w2 that are the distance between the crosswalk and the crossroads, the width of Engels street and the width of Marx street respectively (1 ≤ d, w1, w2 ≤ 106). The third line contains integers t1, t2, t3 and t4, which describe the scheme of the traffic light (1 ≤ t1, t2, t3, t4 ≤ 106). It is guaranteed that w1vt2 and w2vt4. It can be assumed that drivers always give way to pedestrians at the crosswalk. All distances are given in meters, times in seconds and speed in meters per second.


Output two numbers — the probability that at the equiprobable initial state of the traffic light Sergey would reach the cafe faster, crossing Marx street at the crosswalk, and the probability that he would reach faster, crossing both streets at the crossroads. Absolute error of your answer should not exceed 10−9.


10 1 1
4 1 4 1
0.4 0.1
Problem Author: Egor Shchelkonogov
Problem Source: Open Ural FU Personal Contest 2014