1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-09-04 06:51:41 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
Files
leetcode-problemset/leetcode-cn/problem (Chinese)/十六进制和三十六进制转化 [hexadecimal-and-hexatrigesimal-conversion].html
2025-07-17 00:14:36 +08:00

50 lines
2.1 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>给你一个整数 <code>n</code></p>
<p>返回 <code>n<sup>2</sup></code>&nbsp;<strong>十六进制表示</strong><code>n<sup>3</sup></code>&nbsp;<strong>三十六进制表示</strong> 拼接成的字符串。</p>
<p><strong>十六进制&nbsp;</strong>数定义为使用数字 <code>0 9</code> 和大写字母 <code>A - F</code> 表示 0 到 15 的值。</p>
<p><strong>三十六进制&nbsp;</strong>数定义为使用数字 <code>0 9</code> 和大写字母 <code>A - Z</code> 表示 0 到 35 的值。</p>
<p>&nbsp;</p>
<p><strong class="example">示例 1</strong></p>
<div class="example-block">
<p><strong>输入:</strong><span class="example-io">n = 13</span></p>
<p><strong>输出:&nbsp;</strong><span class="example-io">"A91P1"</span></p>
<p><strong>解释:</strong></p>
<ul>
<li><code>n<sup>2</sup> = 13 * 13 = 169</code>。在十六进制中,它转换为 <code>(10 * 16) + 9 = 169</code>,对应于 <code>"A9"</code></li>
<li><code>n<sup>3</sup> = 13 * 13 * 13 = 2197</code>。在三十六进制中,它转换为 <code>(1 * 36<sup>2</sup>) + (25 * 36) + 1 = 2197</code>,对应于 <code>"1P1"</code></li>
<li>连接两个结果得到 <code>"A9" + "1P1" = "A91P1"</code></li>
</ul>
</div>
<p><strong class="example">示例 2</strong></p>
<div class="example-block">
<p><strong>输入:</strong><span class="example-io">n = 36</span></p>
<p><strong>输出:</strong><span class="example-io">"5101000"</span></p>
<p><strong>解释:</strong></p>
<ul>
<li><code>n<sup>2</sup> = 36 * 36 = 1296</code>。在十六进制中,它转换为 <code>(5 * 16<sup>2</sup>) + (1 * 16) + 0 = 1296</code>,对应于 <code>"510"</code></li>
<li><code>n<sup>3</sup> = 36 * 36 * 36 = 46656</code>。在三十六进制中,它转换为 <code>(1 * 36<sup>3</sup>) + (0 * 36<sup>2</sup>) + (0 * 36) + 0 = 46656</code>,对应于 <code>"1000"</code></li>
<li>连接两个结果得到 <code>"510" + "1000" = "5101000"</code></li>
</ul>
</div>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= n &lt;= 1000</code></li>
</ul>