题目描述 给定一个double类型的浮点数base和int类型的整数exponent。求base的exponent次方。 思路 特别注意负数的情况,出现负数,将其转化为正数然后求倒数。 class Solution {public:double Power(double base, int exponent) {double total = 1;bool flag = false
题目: 题解: class Solution {const int MOD = 1337;int pow(int x, int n) {int res = 1;while (n) {if (n % 2) {res = (long) res * x % MOD;}x = (long) x * x % MOD;n /= 2;}return res;}public:int superPow(in
题目: 题解: const mod = 1337func pow(x, n int) int {res := 1for ; n > 0; n /= 2 {if n&1 > 0 {res = res * x % mod}x = x * x % mod}return res}func superPow(a int, b []int) int {ans := 1for _, e := rang
题目: 题解: class Solution {static final int MOD = 1337;public int superPow(int a, int[] b) {int ans = 1;for (int e : b) {ans = (int) ((long) pow(ans, 10) * pow(a, e) % MOD);}return ans;}public int po