mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-11 18:31:41 +08:00
51 lines
2.2 KiB
HTML
51 lines
2.2 KiB
HTML
<p data-end="157" data-start="30">给定一个字符串 <code>s</code>,找出可以由其 <strong>子字符串 </strong>组成的 <strong>3个最大的不同质数 </strong>的和。</p>
|
||
|
||
<p data-end="269" data-start="166">返回这些质数的 <strong>总和 </strong>,如果少于 3 个不同的质数,则返回 <strong>所有 </strong>不同质数的和。</p>
|
||
|
||
<p data-end="269" data-start="166">质数是大于 1 且只有两个因数的自然数:1和它本身。</p>
|
||
|
||
<p data-end="269" data-start="166"><strong>子字符串 </strong>是字符串中的一个连续字符序列。 </p>
|
||
|
||
<p data-end="370" data-is-last-node="" data-is-only-node="" data-start="271"><strong data-end="280" data-start="271">注意:</strong>每个质数即使出现在 <strong>多个 </strong>子字符串中,也只能计算 <strong>一次 </strong>。此外,将子字符串转换为整数时,忽略任何前导零。</p>
|
||
|
||
<p> </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> </p>
|
||
|
||
<p><strong>提示:</strong></p>
|
||
|
||
<ul>
|
||
<li data-end="39" data-start="18"><code>1 <= s.length <= 10</code></li>
|
||
<li data-end="68" data-is-last-node="" data-start="40"><code>s</code> 仅由数字组成。</li>
|
||
</ul>
|