Tap here to switch tabs
Problem
Submissions

Problem: Number of Ways to Build House of Cards

Try to solve the Number of Ways to Build House of Cards problem.

Statement

You are given an integer n representing the total number of playing cards.

A house of cards is constructed according to the following rules:

  • It is composed of 11 or more rows.

  • Each row consists of some positive number of triangles. A single triangle is formed by leaning 22 cards against each other.

  • In a row containing kk triangles, exactly 11 horizontal card is placed between every 22 adjacent triangles, resulting in k−1k - 1 horizontal cards. Consequently, a row with kk triangles uses a total of 3k−13k - 1 cards.

  • Every row above the bottom row must have strictly fewer triangles than the row directly below it.

  • The structure must use all n cards.

Return the total number of distinct valid houses of cards that can be built using exactly n cards.

Constraints:

  • 1≤1 \leq n ≤500\leq 500

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Number of Ways to Build House of Cards

Try to solve the Number of Ways to Build House of Cards problem.

Statement

You are given an integer n representing the total number of playing cards.

A house of cards is constructed according to the following rules:

  • It is composed of 11 or more rows.

  • Each row consists of some positive number of triangles. A single triangle is formed by leaning 22 cards against each other.

  • In a row containing kk triangles, exactly 11 horizontal card is placed between every 22 adjacent triangles, resulting in k−1k - 1 horizontal cards. Consequently, a row with kk triangles uses a total of 3k−13k - 1 cards.

  • Every row above the bottom row must have strictly fewer triangles than the row directly below it.

  • The structure must use all n cards.

Return the total number of distinct valid houses of cards that can be built using exactly n cards.

Constraints:

  • 1≤1 \leq n ≤500\leq 500