1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-09-11 18:31:41 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
Files
leetcode-problemset/leetcode-cn/problem (Chinese)/最大质数子字符串之和 [sum-of-largest-prime-substrings].html
2025-05-25 15:08:47 +08:00

51 lines
2.2 KiB
HTML
Raw 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 data-end="157" data-start="30">给定一个字符串 <code>s</code>,找出可以由其&nbsp;<strong>子字符串&nbsp;</strong>组成的&nbsp;<strong>3个最大的不同质数&nbsp;</strong>的和。</p>
<p data-end="269" data-start="166">返回这些质数的&nbsp;<strong>总和&nbsp;</strong>,如果少于 3 个不同的质数,则返回&nbsp;<strong>所有&nbsp;</strong>不同质数的和。</p>
<p data-end="269" data-start="166">质数是大于 1 且只有两个因数的自然数1和它本身。</p>
<p data-end="269" data-start="166"><strong>子字符串&nbsp;</strong>是字符串中的一个连续字符序列。&nbsp;</p>
<p data-end="370" data-is-last-node="" data-is-only-node="" data-start="271"><strong data-end="280" data-start="271">注意:</strong>每个质数即使出现在&nbsp;<strong>多个&nbsp;</strong>子字符串中,也只能计算&nbsp;<strong>一次&nbsp;</strong>。此外,将子字符串转换为整数时,忽略任何前导零。</p>
<p>&nbsp;</p>
<p><strong class="example">示例 1</strong></p>
<div class="example-block">
<p><strong>输入:</strong> <span class="example-io">s = "12234"</span></p>
<p><strong>输出:</strong> <span class="example-io">1469</span></p>
<p><strong>解释:</strong></p>
<ul>
<li data-end="136" data-start="16"><code>"12234"</code> 的子字符串形成的不同质数为 2 3 23 223 和 1223。</li>
<li data-end="226" data-start="137">最大的 3 个质数是 1223、223 和 23。它们的和是 1469。</li>
</ul>
</div>
<p><strong class="example">示例 2</strong></p>
<div class="example-block">
<p><strong>输入:</strong> <span class="example-io">s = "111"</span></p>
<p><strong>输出:</strong> <span class="example-io">11</span></p>
<p><strong>解释:</strong></p>
<ul>
<li data-end="339" data-start="244"><code>"111"</code> 的子字符串形成的不同质数是 11。</li>
<li data-end="412" data-is-last-node="" data-start="340">由于只有一个质数,所以结果是 11。</li>
</ul>
</div>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li data-end="39" data-start="18"><code>1 &lt;= s.length &lt;= 10</code></li>
<li data-end="68" data-is-last-node="" data-start="40"><code>s</code> 仅由数字组成。</li>
</ul>