#ROOBOT. Robot
Robot
There is a robot on the 2D plane. Robot initially standing on the position (0, 0). Robot can make a 4 different moves:
- Up (from (x, y) to (x, y + 1)) with probability U.
- Right (from (x, y) to (x + 1, y)) with probability R.
- Down (from (x, y) to (x, y - 1)) with probability D.
- Left (from (x, y) to (x - 1, y)) with probability L.
After moving N times Robot gets points.
- Let x1 be the smallest coordinate in X-axis, that Robot reached in some moment.
- Let x2 be the largest coordinate in X-axis, that Robot reached in some moment.
- Let y1 be the smallest coordinate in Y-axis, that Robot reached in some moment.
- Let y2 be the largest coordinate in Y-axis, that Robot reached in some moment.
Points achieved by Robot equals to x2 - x1 + y2 - y1.
Given N, U, R, D, L. Calculate expected value of points that Robot achieved after N moves.
Input
First line: One interger N (1 ≤ N ≤ 200).
Second line: Four real numbers U, R, D, L (U + R + D + L = 1, 0 ≤ U, R, D, L ≤ 1) with maximum of 6 numbers after dot.
Output
One number: expected value of points achieved by Robot. The answer will be considered correct if its relative or absolute error does not exceed 10-6.
Example 1
Input: 2 0.100000 0.200000 0.300000 0.400000 Output: 1.780000
Example 2
Input: 3 0.25 0.25 0.25 0.25 Output: 2.375000