mirror of
https://github.com/CyC2018/Interview-Notebook.git
synced 2026-10-30 18:23:52 +00:00
Update 60. n 个骰子的点数.md
重新绘制配图,配图移到状态定义之后。
This commit is contained in:
@@ -8,14 +8,14 @@
|
||||
|
||||
把 n 个骰子扔在地上,求点数和为 s 的概率。
|
||||
|
||||
<div align="center"> <img src="https://cs-notes-1256109796.cos.ap-guangzhou.myqcloud.com/195f8693-5ec4-4987-8560-f25e365879dd.png" width="300px"> </div><br>
|
||||
|
||||
## 解题思路
|
||||
|
||||
### 动态规划
|
||||
|
||||
使用一个二维数组 dp 存储点数出现的次数,其中 dp\[i]\[j] 表示前 i 个骰子产生点数 j 的次数。
|
||||
|
||||
<div align="center"> <img src="pics/offer-dice-sum.png" width="560px"/> </div><br>
|
||||
|
||||
空间复杂度:O(N<sup>2</sup>)
|
||||
|
||||
```java
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 86 KiB |
Reference in New Issue
Block a user