Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|

Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |

Language: Chess Game
Description There is a kind of chessboard-game which should be played with pure luck. It is always welcomed by children and maybe some teenagers enjoy killing-time with it. The rules of the game are easy to understand. Totally there are For university students, such games looks too simple, or sometimes naïve, but now this game has one more applicationâ€”to evaluate one's RP (which is a very important property in our daily life)! In order to decide whether you have high RP or not, it is quite essential to decide the expectation number of the rounds you can reach the goal, and that is what you should do. To remove ambiguities, we made the following assumptions: 1) Only one instruction should be followed and there is no chain-effect for instructions. For example, if you followed the instruction on grid 15 and go 3 steps forward to grid 18, then you will wait at grid 18 until the next round begins no matter what instructions are in grid 18. 2) One can reach the goal if and only if he arrived exactly on grid N and redundant steps will change directions. For example, the goal is at grid 100 and you are now standing in grid 98, if you roll the dice and get 5 points, then your finally position is in grid 97(98->99->100->99->98->97) if there is no instructions at grid 97. The same rule is adapted to grid 0. 3) The dice is a cube and the probability of getting every kind of points from 1 to 6 is equal to 1/6. 4) There are 3 kind of instructions, go forward for 1 to 6 steps/go backward for 1 to 6 steps/no dice rolling in the next round. Input the information of the chessboard and you should output the expectation number of the rounds you can reach the goal. Input The first line of the input contains one integer The next line contains one integer Following line contains one integer The next line contains one integer Output Output contains only one real number, representing the expectation number of the rounds to reach the goal. The answer should be rounded to 0.01. If it is impossible to reach the goal, print "Impossible" instead. Sample Input 10 1 9 2 2 2 4 4 4 1 5 Sample Output 8.81 Source |

[Submit] [Go Back] [Status] [Discuss]

All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di

Any problem, Please Contact Administrator