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>left</code>&nbsp;和&nbsp;<code>right</code>&nbsp;,满足&nbsp;<code>left &lt;= right</code>&nbsp;。请你计算&nbsp;<strong>闭区间</strong>&nbsp;<code>[left, right]</code>&nbsp;中所有整数的&nbsp;<strong>乘积</strong>&nbsp;。</p>\n\n<p>由于乘积可能非常大,你需要将它按照以下步骤 <strong>缩写</strong>&nbsp;</p>\n\n<ol>\n\t<li>统计乘积中&nbsp;<strong>后缀</strong> 0 的数目,并 <strong>移除</strong> 这些 0 ,将这个数目记为&nbsp;<code>C</code>&nbsp;。\n\n\t<ul>\n\t\t<li>比方说,<code>1000</code>&nbsp;中有 <code>3</code> 个后缀 0&nbsp;<code>546</code>&nbsp;中没有后缀 0 。</li>\n\t</ul>\n\t</li>\n\t<li>将乘积中剩余数字的位数记为&nbsp;<code>d</code>&nbsp;。如果&nbsp;<code>d &gt; 10</code>&nbsp;,那么将乘积表示为&nbsp;<code>&lt;pre&gt;...&lt;suf&gt;</code>&nbsp;的形式,其中&nbsp;<code>&lt;pre&gt;</code>&nbsp;表示乘积最 <strong>开始</strong>&nbsp;的 <code>5</code>&nbsp;个数位,<code>&lt;suf&gt;</code>&nbsp;表示删除后缀 0 <strong>之后</strong>&nbsp;结尾的 <code>5</code>&nbsp;个数位。如果&nbsp;<code>d &lt;= 10</code>&nbsp;,我们不对它做修改。\n\t<ul>\n\t\t<li>比方说,我们将&nbsp;<code>1234567654321</code>&nbsp;表示为&nbsp;<code>12345...54321</code>&nbsp;,但是&nbsp;<code>1234567</code>&nbsp;仍然表示为&nbsp;<code>1234567</code>&nbsp;。</li>\n\t</ul>\n\t</li>\n\t<li>最后,将乘积表示为 <strong>字符串</strong>&nbsp;<code>\"&lt;pre&gt;...&lt;suf&gt;eC\"</code>&nbsp;。\n\t<ul>\n\t\t<li>比方说,<code>12345678987600000</code>&nbsp;被表示为&nbsp;<code>\"12345...89876e5\"</code>&nbsp;。</li>\n\t</ul>\n\t</li>\n</ol>\n\n<p>请你返回一个字符串,表示 <strong>闭区间</strong>&nbsp;<code>[left, right]</code>&nbsp;中所有整数&nbsp;<strong>乘积</strong>&nbsp;的&nbsp;<strong>缩写</strong>&nbsp;。</p>\n\n<p>&nbsp;</p>\n\n<p><strong>示例 1</strong></p>\n\n<pre>\n<b>输入:</b>left = 1, right = 4\n<b>输出:</b>\"24e0\"\n<strong>解释:</strong>\n乘积为 1 × 2 × 3 × 4 = 24 。\n由于没有后缀 0 ,所以 24 保持不变,缩写的结尾为 \"e0\" 。\n因为乘积的结果是 2 位数,小于 10 ,所欲我们不进一步将它缩写。\n所以最终将乘积表示为 \"24e0\" 。\n</pre>\n\n<p><strong>示例 2</strong></p>\n\n<pre>\n<strong>输入:</strong>left = 2, right = 11\n<strong>输出:</strong>\"399168e2\"\n<strong>解释:</strong>乘积为 39916800 。\n有 2 个后缀 0 ,删除后得到 399168 。缩写的结尾为 \"e2\" 。 \n删除后缀 0 后是 6 位数,不需要进一步缩写。 \n所以最终将乘积表示为 \"399168e2\" 。\n</pre>\n\n<p><strong>示例 3</strong></p>\n\n<pre>\n<strong>输入:</strong>left = 371, right = 375\n<strong>输出:</strong>\"7219856259e3\"\n<strong>解释:</strong>乘积为 7219856259000 。\n</pre>\n\n<p>&nbsp;</p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>1 &lt;= left &lt;= right &lt;= 10<sup>4</sup></code></li>\n</ul>\n",
"isPaidOnly": false,
"difficulty": "Hard",
"likes": 4,
"likes": 5,
"dislikes": 0,
"isLiked": null,
"similarQuestions": "[]",
@@ -137,7 +137,7 @@
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"1.1K\", \"totalSubmission\": \"3.3K\", \"totalAcceptedRaw\": 1121, \"totalSubmissionRaw\": 3288, \"acRate\": \"34.1%\"}",
"stats": "{\"totalAccepted\": \"1.2K\", \"totalSubmission\": \"3.5K\", \"totalAcceptedRaw\": 1173, \"totalSubmissionRaw\": 3481, \"acRate\": \"33.7%\"}",
"hints": [
"Calculating the number of trailing zeros, the last five digits, and the first five digits can all be done separately.",
"Use a prime factorization property to find the number of trailing zeros. Use modulo to find the last 5 digits. Use a logarithm property to find the first 5 digits.",