2189. Number of Ways to Build House of Cards
Содержание
class Solution:
def houseOfCards(self, n: int) -> int:
@cache
def dfs(n: int, k: int) -> int:
x = 3 * k + 2
if x > n:
return 0
if x == n:
return 1
return dfs(n - x, k + 1) + dfs(n, k + 1)
return dfs(n, 0)