|
1 | 1 | [#0050-powx-n]
|
2 | 2 | = 50. Pow(x, n)
|
3 | 3 |
|
4 |
| -{leetcode}/problems/powx-n/[LeetCode - Pow(x, n)^] |
| 4 | +https://leetcode.cn/problems/powx-n/[LeetCode - 50. Pow(x, n) ^] |
5 | 5 |
|
6 |
| -Implement http://www.cplusplus.com/reference/valarray/pow/[pow(_x_, _n_)^], which calculates _x_ raised to the power _n_ (x^n^). |
| 6 | +实现 https://www.cplusplus.com/reference/valarray/pow/[pow(x, n)] ,即计算 `x` 的整数 `n` 次幂函数(即,`x^n^`)。 |
7 | 7 |
|
8 |
| -*Example 1:* |
| 8 | +*示例 1:* |
9 | 9 |
|
10 |
| -[subs="verbatim,quotes,macros"] |
11 |
| ----- |
12 |
| -*Input:* 2.00000, 10 |
13 |
| -*Output:* 1024.00000 |
14 |
| ----- |
| 10 | +.... |
| 11 | +输入:x = 2.00000, n = 10 |
| 12 | +输出:1024.00000 |
| 13 | +.... |
15 | 14 |
|
16 |
| -*Example 2:* |
| 15 | +*示例 2:* |
17 | 16 |
|
18 |
| -[subs="verbatim,quotes,macros"] |
19 |
| ----- |
20 |
| -*Input:* 2.10000, 3 |
21 |
| -*Output:* 9.26100 |
22 |
| ----- |
| 17 | +.... |
| 18 | +输入:x = 2.10000, n = 3 |
| 19 | +输出:9.26100 |
| 20 | +.... |
23 | 21 |
|
24 |
| -*Example 3:* |
25 |
| - |
26 |
| -[subs="verbatim,quotes,macros"] |
27 |
| ----- |
28 |
| -*Input:* 2.00000, -2 |
29 |
| -*Output:* 0.25000 |
30 |
| -*Explanation:* 2^-2^ = 1/2^2^ = 1/4 = 0.25 |
31 |
| ----- |
| 22 | +*示例 3:* |
32 | 23 |
|
33 |
| -*Note:* |
| 24 | +.... |
| 25 | +输入:x = 2.00000, n = -2 |
| 26 | +输出:0.25000 |
| 27 | +解释:2-2 = 1/22 = 1/4 = 0.25 |
| 28 | +.... |
34 | 29 |
|
| 30 | +*提示:* |
35 | 31 |
|
36 |
| -* -100.0 < _x_ < 100.0 |
37 |
| -* _n_ is a 32-bit signed integer, within the range [-2^31^, 2^31 ^- 1] |
| 32 | +* `-100.0 < x < 100.0` |
| 33 | +* `-2^31^ \<= n \<= 2^31^-1` |
| 34 | +* `n` 是一个整数 |
| 35 | +* 要么 `x` 不为零,要么 `n > 0` 。 |
| 36 | +* `-10^4^ \<= x^n^ \<= 10^4^` |
38 | 37 |
|
39 | 38 | == 思路分析
|
40 | 39 |
|
@@ -70,11 +69,20 @@ include::{sourcedir}/_0050_PowXN.java[tag=answer]
|
70 | 69 | include::{sourcedir}/_0050_PowXN_2.java[tag=answer]
|
71 | 70 | ----
|
72 | 71 | --
|
| 72 | +
|
| 73 | +三刷:: |
| 74 | ++ |
| 75 | +-- |
| 76 | +[{java_src_attr}] |
| 77 | +---- |
| 78 | +include::{sourcedir}/_0050_PowXN_3.java[tag=answer] |
| 79 | +---- |
| 80 | +-- |
73 | 81 | ====
|
74 | 82 |
|
75 | 83 | == 参考资料
|
76 | 84 |
|
77 |
| -. https://leetcode.cn/problems/powx-n/solutions/238559/powx-n-by-leetcode-solution/?envType=study-plan-v2&envId=selected-coding-interview[50. Pow(x, n) - 官方题解^] |
78 |
| -. https://leetcode.cn/problems/powx-n/solutions/241471/50-powx-n-kuai-su-mi-qing-xi-tu-jie-by-jyd/?envType=study-plan-v2&envId=selected-coding-interview[50. Pow(x, n) - 快速幂,清晰图解^] |
| 85 | +. https://leetcode.cn/problems/powx-n/solutions/238559/powx-n-by-leetcode-solution/[50. Pow(x, n) - 官方题解^] |
| 86 | +. https://leetcode.cn/problems/powx-n/solutions/241471/50-powx-n-kuai-su-mi-qing-xi-tu-jie-by-jyd/[50. Pow(x, n) - 快速幂,清晰图解^] |
79 | 87 |
|
80 | 88 |
|
0 commit comments