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)/数值的整数次方 [shu-zhi-de-zheng-shu-ci-fang-lcof].html
2022-03-29 12:43:11 +08:00

38 lines
1.1 KiB
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>实现 <a href="https://www.cplusplus.com/reference/valarray/pow/">pow(<em>x</em>, <em>n</em>)</a> ,即计算 x 的 n 次幂函数x<sup>n</sup>)。不得使用库函数,同时不需要考虑大数问题。</p>
<p> </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> </p>
<p><strong>提示:</strong></p>
<ul>
<li><code>-100.0 < x < 100.0</code></li>
<li><code>-2<sup>31</sup> <= n <= 2<sup>31</sup>-1</code></li>
<li><code>-10<sup>4</sup> <= x<sup>n</sup> <= 10<sup>4</sup></code></li>
</ul>
<p> </p>
<p>注意:本题与主站 50 题相同:<a href="https://leetcode-cn.com/problems/powx-n/">https://leetcode-cn.com/problems/powx-n/</a></p>