1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-11 02:58:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/Pow(x, n) [powx-n].html

36 lines
1.0 KiB
HTML
Raw Normal View History

2022-03-27 20:56:26 +08:00
<p>实现&nbsp;<a href="https://www.cplusplus.com/reference/valarray/pow/" target="_blank">pow(<em>x</em>, <em>n</em>)</a>&nbsp;,即计算 <code>x</code><code>n</code> 次幂函数(即,<code>x<sup>n</sup></code><sup><span style="font-size:10.8333px"> </span></sup>)。</p>
<p>&nbsp;</p>
<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>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>-100.0 &lt; x &lt; 100.0</code></li>
<li><code>-2<sup>31</sup> &lt;= n &lt;= 2<sup>31</sup>-1</code></li>
<li><code>-10<sup>4</sup> &lt;= x<sup>n</sup> &lt;= 10<sup>4</sup></code></li>
</ul>