In the End
Time limit2sMemory limit512 MB
Each column holds one cake at a random row, and the robot moves right with a row change of at most 1; find the limit of f(m)/m modulo 1e9+7.
- Level
Hard9 of 10
- Topics
- Probability, Dynamic programming, Math
- Solved
- No attempts yet
Problem
The board is infinite in one direction. It has rows and an infinite number of columns, with a first (leftmost) column but no last column. Each column contains exactly one cell with a cake. The cake is in row with probability , and all sum to . Cake positions in different columns are independent. A robot starts in some cell of the first column. If the robot is at cell (row , column ), in one step it can move to , , or , whenever that cell exists. When the robot visits a cell with a cake, it collects that cake. The order of events is as follows: first all cakes are placed according to the given probabilities, then the configuration is given to the robot, and then the robot chooses a starting cell and a movement plan to maximize the number of cakes it collects. For each board of size with , let be the expected average number of cakes collected per step under an optimal route. Compute .
Input
The first line contains an integer (), the number of rows. The next line contains real numbers () with at most one digit after the decimal point. Their sum is .
Output
The answer can be written as a fraction with positive integers and . Print .