• 2274 Get Out of the Glass

    Time Limit : 2000/1000 MS(Java/Others) | Memory Limit : 65536/32768 KB(Java/Others)

    Submits : 60 | Solved : 27

    Description

    Considering a light entering three adjacent planes of glass.
    At any meeting surface, the light may either reflect or continue straight through. For example, here is the light bouncing five times before it leaves the glass.
    
    Given the times the light bounces before leaving the glass, you are asked to tell how many different paths the light can take before leaving the glass.
    

    Input

    Input contains serverl test cases, each test case contains only one integer n (0 <= n <= 50) indicates how many bounces the light take.

    Output

    Output how many different paths the light can take.

    Sample Input

    0
    1
    

    Sample Output

    1
    3
    

    HINT

    n = 0, the light leave the glass without any bounces, it go straight through the glass.
    n = 1, there are three ways for the light to travel with one bounce--bounce at the middle two meeting faces plus the bottom one.
    

    Source

    ZOJ Monthly, October 2006

    [ Top ] | [ Submit ] | [ Statistics ] | [ Standing ]