Correct expressions P68813


Statement
 

pdf   zip

In this problem we consider the expressions defined as follows:

  • Every variable is a correct expresion;

  • if xx is a correct expression, so is (x)(x);

  • if x1x_1 and x2x_2 are correct expressions, so are (x1)(x2)(x_1) - (x_2);

  • nothing else is a correct expression.

For instance, if the set of variables is A,B,C{A, B, C}, these are some correct expressions:

A(A)((C))(A)(B)((A)(B))(A)A \qquad (A) \qquad ((C)) \qquad (A)-(B) \qquad ((A)-(B))-(A)

Write a program that, given two numbers nn and mm, prints the number of correct expressions of length exactly nn that can be made up with mm variables.

For instance, for n=7n =7 and m=2m=2 the result should be 6, corresponding to

(((A)))(((B)))(A)(A)(A)(B)(B)(A)(B)(B)(((A))) \qquad (((B))) \qquad (A)-(A) \qquad (A)-(B) \qquad (B)-(A) \qquad (B)-(B)

Input

Input consists of several cases, each with two natural numbers nn and mm between 11 and 2525.

Output

For every case, print the number of correct expressions of length exactly nn that can be made up with mm variables. This number will always be smaller than 10910^9.

Public test cases
  • Input

    7 2
    1 20
    20 1
    21 1
    25 25
    

    Output

    6
    20
    0
    212
    307378150
    
  • Information
    Author
    Omer Giménez
    Language
    English
    Translator
    Salvador Roura
    Original language
    Catalan
    Other languages
    Catalan Spanish
    Official solutions
    C++
    User solutions
    C++ Python