h, w = int(input()), int(input())
grid = [[False]*w for _ in range(h)]

def backtrack(x, y):
    count = 0
    while y < h and grid[y][x]: # Recherche de la prochaine case vide
        x += 1
        if x >= w:
            x = 0
            y += 1
    if y >= h: # Plus de case vide, on a tout rempli
        return 1
    # Est-ce qu'on peut placer une brique horizontale ?
    if x < w - 1 and not grid[y][x + 1]:
        grid[y][x] = True
        grid[y][x + 1] = True
        count += backtrack(x, y)
        grid[y][x] = False
        grid[y][x + 1] = False
    # Est-ce qu'on peut placer une brique verticale ?
    if y < h - 1 and not grid[y + 1][x]:
        grid[y][x] = True
        grid[y + 1][x] = True
        count += backtrack(x, y)
        grid[y][x] = False
        grid[y + 1][x] = False
    return count

print(backtrack(0, 0))

Embed on website

To embed this program on your website, copy the following code and paste it into your website's HTML: