Skip to content

Commit

Permalink
Update Readme.md
Browse files Browse the repository at this point in the history
  • Loading branch information
wisdompeak authored May 16, 2021
1 parent 34b05f1 commit 9cd66b1
Showing 1 changed file with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,6 @@
同样,也可以从传统的动态规划角度去解释。令dp[i][j]表示前i个柱子里我们能看到j个。现在考虑第i个柱子:
1. 第i个柱子因为是当前最高的柱子,自己构成一个新的“牌面担当”,方案数等同于```dp[i-1][j-1]```
2. 前i-1个柱子已经有了j个“牌面担当”(对应构成j个区间),那么第i个数可以插入这j个区间的任意位置,但必须稍微做些变化,即取代该区间成为新的“大哥”。总共有i-1个位置。即```dp[i-1][j]*(i-1)```

综上递推公式 ```dp[i][j] = dp[i-1][j-1] + dp[i-1][j]*(i-1)```

0 comments on commit 9cd66b1

Please sign in to comment.