spoj#DEC123. Decorating the Palace

Decorating the Palace

Problem Statement:
    King of DragonLand likes decorating towers , So one day he decided to decorate  a tower with flowers.
    Heighest floor of tower contains only one room and floor just below every floor except the base floor ,  will have two of it's child buildings on which it is built,
    Note that it's structure is like a binary tree .
    
    for height = 3    
    
                 *
            *       *
          *   *   *  *
    
    You are given the task of decorating it, But there is a constraint in decorating it , Sum of child floors of a floor will have be equal to no of flowers in parent building and your child floors will have as less difference between number of flowers in them as possible to look your tower beautiful.

    Given that top building contains N flowers and Height of tower H , find out no of ways of decorating it , As this value may be large , output it's modulo 10^ 9 + 7.
    Two decorations are considered different if any floor in them contains different no of flowers
    
    Input :
    T: no of test cases (<= 10)
    than next T line contain H , N
    
    Output : no of different decorations % (10 ^ 9 + 7)
    
    constraint : 1<=H<=50
                 1<=N<=50000
    Example:
    Input:
            2
            1 1

           2 1
    Output:
            1

               2

 

Explanation:

for 1 1 , it is obvious.

for 2 1 ,

There can be two ways: 

     1

1      0

    1

0       1