ENG  RUSTimus Online Judge
Online Judge
Online contests
About Online Judge
Frequently asked questions
Site news
Problem set
Submit solution
Judge status
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests

Open Ural FU Championship 2012

About     Problems     Submit solution     Judge status     Standings
Contest is over

F. Roshambo

Time limit: 1.0 second
Memory limit: 64 MB
Bootstrap: Wondering how it's played?
Will: It's a game of deception. But your bet includes all the dice, not just your own. What are they wagering?
Bootstrap: Oh, the only thing we have. Years of service.
Will: So any crew member can be challenged?
Bootstrap: Aye. Anyone.
Will: I challenge Davy Jones.
All that the pirates have on the Flying Dutchman is the years of service that are left for them. Every crewman wants to shorten it. That is why gambling is very popular on the ship, the winner have a chance to shorten his years of service significantly.
Pirates often gather to play “Roshambo”, also known as “rock-scissors-paper”. The game consists of several sets. In the beginning of each set players stand in a circle, count to three and show one of three gestures simultaneously, conventionally called as rock, scissors and paper. If everyone shows the same gesture or if each of the three gestures is shown, then nobody leave the game and they play another set. If among the shown gestures there are only two different then only players that chose the victorious gesture play the next set. Scissors beats rock, rock beats paper and paper beats scissors. The game continues until the only one player is left, and that pirate is called the winner. The winner’s time of service is shortened on the number of years that equals the number of the sets played, while the losers get extra years.
Bootstrap Bill decided to try his fortune. You should help him determine the expected value of prize in case of his victory. Pirates don’t know any complicated strategies for this game. So you can suppose that pirates show every gesture equiprobably.


The only line contains integer n that is the number of sailors that are going to play, including Bill (2 ≤ n ≤ 100).


Output the expected amount of years that will be taken off from winner. Absolute or relative error should be no more than 10−6.


Problem Author: Denis Dublennykh (prepared by Oleg Dolgorukov)
Problem Source: Open Ural FU Championship 2012
To submit the solution for this problem go to the Problem set: 1936. Roshambo