Problem G. Gandalf and Trolls

Author:N. Grebenyuk, A. Usmanov. Translation: A. Logutova.   Time limit:2 sec
Input file:Standard input   Memory limit:512 Mb
Output file:Standard output  

Statement

Trolls surrounded Gandalf the Grey in a cave. Initial distance between the wizard and the nearest troll is R meters. Trolls run T meters every second. At the end of each second Gandalf throws the trolls back to D meters by the magic ring of light.

But there is a problem — angry Saruman the White cursed Gandalf's staff, and now it works only with some probability P.

The trolls will turn into the stone when sunshine lights up the room. Gandalf needs to know how many chances he has to stay alive until the sunrise. Sunrise time is S seconds. Gandalf will die if the distance between him and trolls become less than 1 meter before sunrise.

Input format

The first line contains four integers R, D, T, S.

The second line contains a real number P. P is given with at most 5 digits after the decimal point.

Output format

Print a real number — probability that Gandalf will stay alive until dawn.

Your answer will be accepted if it has absolute error at most 10 − 5. More specifically, if your answer is a and the jury answer is b, your answer will be accepted if |a − b| ≤ 10 − 5.

Constraints

1 ≤ R ≤ 50000

1 ≤ D, T ≤ 100

1 ≤ S ≤ 500

0 ≤ P ≤ 1

Sample tests

No. Standard input Standard output
1
10 10 10 1
1.0
0.00000
2
15 6 10 2
0.7
0.70000
3
7 1 2 3
0.0
1.00000
4
50000 100 100 500
0.0
0.00000
5
100 99 1 500
0.01
0.33301

0.136s 0.015s 13