1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-09-07 08:21:41 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
This commit is contained in:
2022-05-02 23:44:12 +08:00
parent 7ea03594b3
commit 2a71c78585
4790 changed files with 11696 additions and 10944 deletions

View File

@@ -12,7 +12,7 @@
"translatedContent": "<p>给你一个&nbsp;<code>rows x cols</code>&nbsp;大小的矩形披萨和一个整数 <code>k</code>&nbsp;,矩形包含两种字符:&nbsp;<code>&#39;A&#39;</code> (表示苹果)和&nbsp;<code>&#39;.&#39;</code>&nbsp;(表示空白格子)。你需要切披萨 <code>k-1</code> 次,得到&nbsp;<code>k</code>&nbsp;块披萨并送给别人。</p>\n\n<p>切披萨的每一刀,先要选择是向垂直还是水平方向切,再在矩形的边界上选一个切的位置,将披萨一分为二。如果垂直地切披萨,那么需要把左边的部分送给一个人,如果水平地切,那么需要把上面的部分送给一个人。在切完最后一刀后,需要把剩下来的一块送给最后一个人。</p>\n\n<p>请你返回确保每一块披萨包含&nbsp;<strong>至少</strong>&nbsp;一个苹果的切披萨方案数。由于答案可能是个很大的数字,请你返回它对 10^9 + 7 取余的结果。</p>\n\n<p>&nbsp;</p>\n\n<p><strong>示例 1</strong></p>\n\n<p><strong><img alt=\"\" src=\"https://assets.leetcode-cn.com/aliyun-lc-upload/uploads/2020/05/10/ways_to_cut_apple_1.png\" style=\"height: 378px; width: 500px;\"></strong></p>\n\n<pre><strong>输入:</strong>pizza = [&quot;A..&quot;,&quot;AAA&quot;,&quot;...&quot;], k = 3\n<strong>输出:</strong>3 \n<strong>解释:</strong>上图展示了三种切披萨的方案。注意每一块披萨都至少包含一个苹果。\n</pre>\n\n<p><strong>示例 2</strong></p>\n\n<pre><strong>输入:</strong>pizza = [&quot;A..&quot;,&quot;AA.&quot;,&quot;...&quot;], k = 3\n<strong>输出:</strong>1\n</pre>\n\n<p><strong>示例 3</strong></p>\n\n<pre><strong>输入:</strong>pizza = [&quot;A..&quot;,&quot;A..&quot;,&quot;...&quot;], k = 1\n<strong>输出:</strong>1\n</pre>\n\n<p>&nbsp;</p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>1 &lt;= rows, cols &lt;= 50</code></li>\n\t<li><code>rows ==&nbsp;pizza.length</code></li>\n\t<li><code>cols ==&nbsp;pizza[i].length</code></li>\n\t<li><code>1 &lt;= k &lt;= 10</code></li>\n\t<li><code>pizza</code>&nbsp;只包含字符&nbsp;<code>&#39;A&#39;</code>&nbsp;和&nbsp;<code>&#39;.&#39;</code>&nbsp;。</li>\n</ul>\n",
"isPaidOnly": false,
"difficulty": "Hard",
"likes": 54,
"likes": 55,
"dislikes": 0,
"isLiked": null,
"similarQuestions": "[]",
@@ -155,7 +155,7 @@
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"3K\", \"totalSubmission\": \"5.6K\", \"totalAcceptedRaw\": 2981, \"totalSubmissionRaw\": 5631, \"acRate\": \"52.9%\"}",
"stats": "{\"totalAccepted\": \"3.1K\", \"totalSubmission\": \"5.8K\", \"totalAcceptedRaw\": 3063, \"totalSubmissionRaw\": 5754, \"acRate\": \"53.2%\"}",
"hints": [
"Note that after each cut the remaining piece of pizza always has the lower right coordinate at (rows-1,cols-1).",
"Use dynamic programming approach with states (row1, col1, c) which computes the number of ways of cutting the pizza using \"c\" cuts where the current piece of pizza has upper left coordinate at (row1,col1) and lower right coordinate at (rows-1,cols-1).",