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)/判断一个数字是否可以表示成三的幂的和 [check-if-number-is-a-sum-of-powers-of-three].html
2022-03-29 12:43:11 +08:00

34 lines
905 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>n</code> 表示成若干个不同的三的幂之和,请你返回 <code>true</code> ,否则请返回 <code>false</code> 。</p>
<p>对于一个整数 <code>y</code> ,如果存在整数 <code>x</code> 满足 <code>y == 3<sup>x</sup></code> ,我们称这个整数 <code>y</code> 是三的幂。</p>
<p> </p>
<p><strong>示例 1</strong></p>
<pre><b>输入:</b>n = 12
<b>输出:</b>true
<b>解释:</b>12 = 3<sup>1</sup> + 3<sup>2</sup>
</pre>
<p><strong>示例 2</strong></p>
<pre><b>输入:</b>n = 91
<b>输出:</b>true
<b>解释:</b>91 = 3<sup>0</sup> + 3<sup>2</sup> + 3<sup>4</sup>
</pre>
<p><strong>示例 3</strong></p>
<pre><b>输入:</b>n = 21
<b>输出:</b>false
</pre>
<p> </p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= n &lt;= 10<sup>7</sup></code></li>
</ul>