mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-13 11:21:42 +08:00
add leetcode problem-cn part6
This commit is contained in:
45
算法题(国内版)/problem (Chinese)/3 的幂 [power-of-three].html
Normal file
45
算法题(国内版)/problem (Chinese)/3 的幂 [power-of-three].html
Normal file
@@ -0,0 +1,45 @@
|
||||
<p>给定一个整数,写一个函数来判断它是否是 3 的幂次方。如果是,返回 <code>true</code> ;否则,返回 <code>false</code> 。</p>
|
||||
|
||||
<p>整数 <code>n</code> 是 3 的幂次方需满足:存在整数 <code>x</code> 使得 <code>n == 3<sup>x</sup></code></p>
|
||||
|
||||
<p> </p>
|
||||
|
||||
<p><strong>示例 1:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>输入:</strong>n = 27
|
||||
<strong>输出:</strong>true
|
||||
</pre>
|
||||
|
||||
<p><strong>示例 2:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>输入:</strong>n = 0
|
||||
<strong>输出:</strong>false
|
||||
</pre>
|
||||
|
||||
<p><strong>示例 3:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>输入:</strong>n = 9
|
||||
<strong>输出:</strong>true
|
||||
</pre>
|
||||
|
||||
<p><strong>示例 4:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>输入:</strong>n = 45
|
||||
<strong>输出:</strong>false
|
||||
</pre>
|
||||
|
||||
<p> </p>
|
||||
|
||||
<p><strong>提示:</strong></p>
|
||||
|
||||
<ul>
|
||||
<li><code>-2<sup>31</sup> <= n <= 2<sup>31</sup> - 1</code></li>
|
||||
</ul>
|
||||
|
||||
<p> </p>
|
||||
|
||||
<p><strong>进阶:</strong>你能不使用循环或者递归来完成本题吗?</p>
|
Reference in New Issue
Block a user