Chained pawns P56272


Statement
 

pdf   zip

html

In chess, a pawn is a piece that only threatens two squares, namely those diagonally in front of it (if these squares exist). For instance, in this example with five rows and seven columns, the pawn at c4 threatens b3 and d3, the pawn at a2 only threatens b1, the pawn at g5 only threatens f4, and the pawn at e1 threatens no square. (In a real chess game, no pawn can be on the first row or on the last row, but we forget that rule here.)

showmover=false, maxfield=g5, setpieces=pc4,pa2,pg5,pe1

Given the number of rows r and the number of columns c of the board, can you compute the number of ways to place r black pawns on the board so that every pawn but one threatens exactly another pawn and every pawn but one is threatened exactly by another pawn?

Input

Input consists of several cases, each one with r and c. Assume 1≤ r≤ 50 and 1≤ c≤ 50.

Output

For every case, print the corresponding answer. The decimal representation of each answer requires less than 18 digits.

Public test cases
  • Input

    1 9
    4 2
    5 7
    

    Output

    9
    2
    74
    
  • Information
    Author
    Salvador Roura
    Language
    English
    Official solutions
    C++
    User solutions
    C++
    Event
    Primer Concurs de Programació de la UPC - Final
    Date
    2003-09-23