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)/K 进制表示下的各位数字总和 [sum-of-digits-in-base-k].html
2022-03-29 12:43:11 +08:00

31 lines
950 B
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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><code>10</code> 进制)和一个基数 <code>k</code> ,请你将 <code>n</code><code>10</code> 进制表示转换为 <code>k</code> 进制表示,计算并返回转换后各位数字的 <strong>总和</strong></p>
<p>转换后,各位数字应当视作是 <code>10</code> 进制数字,且它们的总和也应当按 <code>10</code> 进制表示返回。</p>
<p> </p>
<p><strong>示例 1</strong></p>
<pre>
<strong>输入:</strong>n = 34, k = 6
<strong>输出:</strong>9
<strong>解释:</strong>34 (10 进制) 在 6 进制下表示为 54 。5 + 4 = 9 。
</pre>
<p><strong>示例 2</strong></p>
<pre>
<strong>输入:</strong>n = 10, k = 10
<strong>输出:</strong>1
<strong>解释:</strong>n 本身就是 10 进制。 1 + 0 = 1 。
</pre>
<p> </p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 <= n <= 100</code></li>
<li><code>2 <= k <= 10</code></li>
</ul>