eolymp
bolt
Try our new interface for solving problems
Problems

Casino

Casino

Consider the following dice game. Player rolls a regular dice (with the numbers 1 through 6 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 21, 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 Sp points and croupier has Sc points, than player wins if and only if (Sp21 and (Sc > 21 or Sc < Sp)).

The optimal croupier's strategy allows casino to win in more than 2 / 3 cases. But Andrew found the possibility to raise his chances to win! He will play together with Big Man. Big Man will bet x euros each game, while Andrew will bet 1 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. Than 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 x is big enough, he has almost 50% chance to win!

Input

Contains one integer x (0x1000).

Output

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

Time limit 1 second
Memory limit 128 MiB
Input example #1
0
Output example #1
0.331176
Input example #2
1
Output example #2
0.345634
Source 2007 Петрозаводск, Saratov for Karelia with love, Январь 28, Задача C