Casino#8496

Casino

1 Sekunde
128 Megabyte
Sehr schwer

Consider the following dice game. Player rolls a regular dice (with the numbers through on its sides) several times and calculates total amount of points each time. Player can finish his turn after any roll. Thus, player should make at least one roll. If the sum exceeds , player loses. When player finishes, croupier rolls a dice using the same scheme. Player wins, if he or she has more points than croupier. More formally, if player has S_p points and croupier has S_c points, than player wins if and only if (S_p ≤ and (S_c > or S_c < S_p)).

The optimal croupier's strategy allows casino to win in more than cases. But Andrew found the possibility to raise his chances to win! He will play together with Big Man. Big Man will bet euros each game, while Andrew will bet euro each game. In case of the win player gets his bet doubled. In case of the loss player gets nothing.

The scheme of the game is like following.

  1. Big Man rolls dice several times and stops following the "best" strategy - the strategy that would be optimal if he played with croupier and without Andrew (he is really Big and doesn't care about little Andrew).

  2. Then Andrew rolls dice several times. Andrew knows the amount of points Big Man has. Andrew is very smart boy and he realizes that croupier's strategy maximizes profit of the casino. So, Andrew uses optimal strategy using all those facts.

  3. Finally, croupier rolls dice several times. As mentioned above, croupier uses optimal strategy.

We call strategy optimal if it maximizes expected profit. If after the next roll any player or croupier have the same expected profit with the current value, he or she will prefer to roll the dice.

As Andrew calculated if is big enough, he has almost chance to win!

Eingabe

Contains one integer (0 \le x \le 1000).

Ausgabe

Print one number - probability of Andrew's win. Your answer must be accurate up to 10^{-5}.

Beispiele

Beispiel 1

Loading
Loading

Beispiel 2

Loading
Loading