Chained pawns

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.)

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.

Problem information

Author: Salvador Roura

Generation: 2026-01-25T11:21:52.426Z

© Jutge.org, 2006–2026.
https://jutge.org
