1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-12-20 19:03:47 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
Files
leetcode-problemset/leetcode-cn/problem (Chinese)/连接非零数字并乘以其数字和 I [concatenate-non-zero-digits-and-multiply-by-sum-i].html
2025-12-06 16:04:11 +08:00

49 lines
1.5 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<p>给你一个整数 <code>n</code></p>
<p><code>n</code> 中所有的&nbsp;<strong>非零数字&nbsp;</strong>按照它们的原始顺序连接起来,形成一个新的整数 <code>x</code>。如果不存在&nbsp;<strong>非零数字&nbsp;</strong>,则 <code>x = 0</code></p>
<p><code>sum</code><code>x</code> 中所有数字的&nbsp;<strong>数字和&nbsp;</strong></p>
<p>返回一个整数,表示 <code>x * sum</code> 的值。</p>
<p>&nbsp;</p>
<p><strong class="example">示例 1</strong></p>
<div class="example-block">
<p><strong>输入:</strong> <span class="example-io">n = 10203004</span></p>
<p><strong>输出:</strong> <span class="example-io">12340</span></p>
<p><strong>解释:</strong></p>
<ul>
<li>非零数字是 1、2、3 和 4。因此<code>x = 1234</code></li>
<li>数字和为 <code>sum = 1 + 2 + 3 + 4 = 10</code></li>
<li>因此,答案是 <code>x * sum = 1234 * 10 = 12340</code></li>
</ul>
</div>
<p><strong class="example">示例 2</strong></p>
<div class="example-block">
<p><strong>输入:</strong> <span class="example-io">n = 1000</span></p>
<p><strong>输出:</strong> <span class="example-io">1</span></p>
<p><strong>解释:</strong></p>
<ul>
<li>非零数字是 1因此 <code>x = 1</code><code>sum = 1</code></li>
<li>因此,答案是 <code>x * sum = 1 * 1 = 1</code></li>
</ul>
</div>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>0 &lt;= n &lt;= 10<sup>9</sup></code></li>
</ul>