National Olympiad in Informatics, China, 1999
On a triangular wooden board placed upright, there are nails and slots (the first figure below depicts the board for ). The distance from each nail to a surrounding nail is , and the width of each slot is also . With the exception of the leftmost and rightmost slots, each slot perfectly aligns with the spaces formed by the bottommost row of nails.
Let a ball of radius start at the center of the topmost nail of the board and naturally roll down. Every time the ball hits a nail, it has the chance of falling towards the left or towards the right (each has a probability), directly on top of the next nail below it. The second figure below depicts one possible route for the ball.
We know that the probability of the ball landing in the -th slot is , where the slots are numbered from left to right.
After pulling out some nails, the problem now is to find the probability of the ball landing in slot . Assume that no nails will be pulled from the bottommost row. The third figure below depicts one possible way that the ball can fall after some nails have been removed.
Input Specification
The first line of input contains the two integers
and . The remaining lines depict the rows
of nails on the board. A *
indicates that the nail is still there,
while a .
indicates that the nail has been pulled out. Note that
among each of these lines, spaces may appear anywhere.
Output Specification
Output one line containing a reduced fraction ( is written as ), the probability of the ball landing in slot . A reduced fraction is defined as the value , where and are integers that do not share any common factor greater than .
Sample Input
5 2
*
* .
* * *
* . * *
* * * * *
Sample Output
7/16
Problem translated to English by .
Comments