1from math import log234class Solution:5def powerfulIntegers(self, x: int, y: int, bound: int) -> List[int]:6if bound == 0:7return []8maxi = int(log(bound, max(x, 2))) + 19maxj = int(log(bound, max(y, 2))) + 110L = set()11for i in range(maxi):12for j in range(maxj):13if (t := x**i + y**j) <= bound:14L.add(t)15else:16break17return list(L)