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
猜你喜欢
转载自blog.csdn.net/m0_37770463/article/details/88795741
今日推荐
周排行