1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-11 11:08:15 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/Pow(x, n) [shu-zhi-de-zheng-shu-ci-fang-lcof].html

40 lines
1.1 KiB
HTML
Raw Normal View History

2023-12-09 18:42:21 +08:00
<p>实现&nbsp;<a href="https://www.cplusplus.com/reference/valarray/pow/">pow(<em>x</em>,&nbsp;<em>n</em>)</a>&nbsp;,即计算 x 的 n 次幂函数x<sup>n</sup>)。</p>
2022-03-27 20:38:29 +08:00
2023-12-09 18:42:21 +08:00
<p>&nbsp;</p>
2022-03-27 20:38:29 +08:00
<p><strong>示例 1</strong></p>
<pre>
<strong>输入:</strong>x = 2.00000, n = 10
<strong>输出:</strong>1024.00000
</pre>
<p><strong>示例 2</strong></p>
<pre>
<strong>输入:</strong>x = 2.10000, n = 3
<strong>输出:</strong>9.26100</pre>
<p><strong>示例 3</strong></p>
<pre>
<strong>输入:</strong>x = 2.00000, n = -2
<strong>输出:</strong>0.25000
<strong>解释:</strong>2<sup>-2</sup> = 1/2<sup>2</sup> = 1/4 = 0.25</pre>
2023-12-09 18:42:21 +08:00
<p>&nbsp;</p>
2022-03-27 20:38:29 +08:00
<p><strong>提示:</strong></p>
<ul>
2023-12-09 18:42:21 +08:00
<li><code>-100.0 &lt;&nbsp;x&nbsp;&lt; 100.0</code></li>
<li><code>-2<sup>31</sup>&nbsp;&lt;= n &lt;=&nbsp;2<sup>31</sup>-1</code></li>
<li><code>-10<sup>4</sup>&nbsp;&lt;= x<sup>n</sup>&nbsp;&lt;= 10<sup>4</sup></code></li>
2022-03-27 20:38:29 +08:00
</ul>
2023-12-09 18:42:21 +08:00
<p>&nbsp;</p>
2022-03-27 20:38:29 +08:00
<p>注意:本题与主站 50 题相同:<a href="https://leetcode-cn.com/problems/powx-n/">https://leetcode-cn.com/problems/powx-n/</a></p>
2023-12-09 18:42:21 +08:00
<p>&nbsp;</p>