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>给你一个用无限二维网格表示的花园,<strong>每一个</strong>&nbsp;整数坐标处都有一棵苹果树。整数坐标&nbsp;<code>(i, j)</code>&nbsp;处的苹果树有 <code>|i| + |j|</code>&nbsp;个苹果。</p>\n\n<p>你将会买下正中心坐标是 <code>(0, 0)</code>&nbsp;的一块 <strong>正方形土地</strong>&nbsp;,且每条边都与两条坐标轴之一平行。</p>\n\n<p>给你一个整数&nbsp;<code>neededApples</code>&nbsp;,请你返回土地的&nbsp;<strong>最小周长</strong>&nbsp;,使得&nbsp;<strong>至少</strong>&nbsp;有<strong>&nbsp;</strong><code>neededApples</code>&nbsp;个苹果在土地&nbsp;<strong>里面或者边缘上</strong>。</p>\n\n<p><code>|x|</code>&nbsp;的值定义为:</p>\n\n<ul>\n\t<li>如果&nbsp;<code>x &gt;= 0</code>&nbsp;,那么值为&nbsp;<code>x</code></li>\n\t<li>如果&nbsp;<code>x &lt;&nbsp;0</code>&nbsp;,那么值为&nbsp;<code>-x</code></li>\n</ul>\n\n<p>&nbsp;</p>\n\n<p><strong>示例 1</strong></p>\n<img alt=\"\" src=\"https://pic.leetcode-cn.com/1627790803-qcBKFw-image.png\" style=\"width: 442px; height: 449px;\" />\n<pre>\n<b>输入:</b>neededApples = 1\n<b>输出:</b>8\n<b>解释:</b>边长长度为 1 的正方形不包含任何苹果。\n但是边长为 2 的正方形包含 12 个苹果(如上图所示)。\n周长为 2 * 4 = 8 。\n</pre>\n\n<p><strong>示例 2</strong></p>\n\n<pre>\n<b>输入:</b>neededApples = 13\n<b>输出:</b>16\n</pre>\n\n<p><strong>示例 3</strong></p>\n\n<pre>\n<b>输入:</b>neededApples = 1000000000\n<b>输出:</b>5040\n</pre>\n\n<p>&nbsp;</p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>1 &lt;= neededApples &lt;= 10<sup>15</sup></code></li>\n</ul>\n",
"isPaidOnly": false,
"difficulty": "Medium",
"likes": 14,
"likes": 17,
"dislikes": 0,
"isLiked": null,
"similarQuestions": "[]",
@@ -143,7 +143,7 @@
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"4.8K\", \"totalSubmission\": \"9.8K\", \"totalAcceptedRaw\": 4763, \"totalSubmissionRaw\": 9814, \"acRate\": \"48.5%\"}",
"stats": "{\"totalAccepted\": \"4.9K\", \"totalSubmission\": \"10.1K\", \"totalAcceptedRaw\": 4898, \"totalSubmissionRaw\": 10057, \"acRate\": \"48.7%\"}",
"hints": [
"Find a formula for the number of apples inside a square with a side length L.",
"Iterate over the possible lengths of the square until enough apples are collected."