import math
class Solution(object):
def powerfulIntegers(self, x, y, bound):
pow = []
x1 = int(math.log(bound, x)) if x!=1 else 1
y1 = int(math.log(bound, y)) if y!=1 else 1
for i in range(x1+1):
for j in range(y1+1):
if x**i+y**j <= bound:
if x**i+y**j not in pow:
pow.append(x**i+y**j)
return pow
Powerful Integers
最新推荐文章于 2021-09-02 00:57:30 发布