
class Solution(object):
def superPow(self, a, b):
"""
:type a: int
:type b: List[int]
:rtype: int
"""
b_num = 0
for i in b:
b_num = b_num * 10
b_num += i
return self.pow(a, b_num)
def pow(self, a, b):
res = 1
base = a
while b > 0:
i = b & 1
b = b >> 1
if i:
res = base * res % 1337
base = base * base % 1337
return res
网友评论