50. Pow(x, n)

xiaoxiao2021-02-28  33

1.换底公式

public class Solution { public double myPow(double x, int n) { int sign = 1; if( x < 0 && n % 2 == 1){ sign = -1; } x = Math.abs(x); return sign * Math.exp(n * Math.log(x)); } } 2.

转载请注明原文地址: https://www.6miu.com/read-55659.html

最新回复(0)