1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-10 18:48:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/找出最大的 N 位 K 回文数 [find-the-largest-palindrome-divisible-by-k].html
2024-08-27 23:06:51 +08:00

56 lines
1.6 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>给你两个 <strong>正整数</strong> <code>n</code><code>k</code></p>
<p>如果整数 <code>x</code> 满足以下全部条件,则该整数是一个 <strong>k 回文数</strong></p>
<ul>
<li><code>x</code> 是一个 <span data-keyword="palindrome-integer">回文数</span></li>
<li><code>x</code> 可以被 <code>k</code> 整除。</li>
</ul>
<p>以字符串形式返回 <strong>最大的&nbsp;</strong> <code>n</code><strong>k 回文数</strong></p>
<p><strong>注意</strong>,该整数 <strong></strong>含前导零。</p>
<p>&nbsp;</p>
<p><strong class="example">示例 1</strong></p>
<div class="example-block">
<p><strong>输入:</strong> <span class="example-io">n = 3, k = 5</span></p>
<p><strong>输出:</strong> <span class="example-io">"595"</span></p>
<p><strong>解释:</strong></p>
<p>595 是最大的 3 位 k 回文数。</p>
</div>
<p><strong class="example">示例 2</strong></p>
<div class="example-block">
<p><strong>输入:</strong> <span class="example-io">n = 1, k = 4</span></p>
<p><strong>输出:</strong> <span class="example-io">"8"</span></p>
<p><strong>解释:</strong></p>
<p>1 位 k 回文数只有 4 和 8。</p>
</div>
<p><strong class="example">示例 3</strong></p>
<div class="example-block">
<p><strong>输入:</strong> <span class="example-io">n = 5, k = 6</span></p>
<p><strong>输出:</strong> <span class="example-io">"89898"</span></p>
</div>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= n &lt;= 10<sup>5</sup></code></li>
<li><code>1 &lt;= k &lt;= 9</code></li>
</ul>