Switches
Consider a game involving four switches, each represented by a non-negative integer indicating its position. The first switch can be set between 0 and a, the second between 0 and b, the third between 0 and c, and the fourth between 0 and d.
Initially, all switches are at position 0. The objective is to move each switch to its maximum position—a, b, c, and d respectively—in the fewest moves possible.
During each move, you can choose one switch that is not yet at its maximum position and increase its value by 1. Simultaneously, each of the other switches may independently change its position: with equal probability, a switch can increase by 1, decrease by 1, or stay the same. If a switch is at position 0, it can only increase by 1 or remain unchanged. Similarly, if a switch is at its maximum position, it can only decrease by 1 or remain unchanged, each with equal probability.
Your task is to calculate the average number of moves needed to bring all switches from position (0, 0, 0, 0) to (a, b, c, d), assuming optimal play.
Input
The input consists of a single line with four integers a, b, c, and d (1 ≤ a, b, c, d ≤ 4).
Output
Output a single number representing the expected number of moves required to complete the game optimally, with a precision of at least 10^{-6}.