给定三个整数 x 、 y 和 bound ,返回 值小于或等于 bound 的所有 强整数 组成的列表 。

如果某一整数可以表示为 xi + yj ,其中整数 i >= 0 且 j >= 0,那么我们认为该整数是一个 强整数 。

你可以按 任何顺序 返回答案。在你的回答中,每个值 最多 出现一次。

链接:https://leetcode.cn/problems/powerful-integers

import math
class Solution(object):
    def powerfulIntegers(self, x, y, bound):
        """
        :type x: int
        :type y: int
        :type bound: int
        :rtype: List[int]
        """
        
        res = []
        for i in range(0, bound):
            if math.pow(x, i) > bound:
                break
            for j in range(0, bound):
                if math.pow(y, j) > bound:
                    break
            
                sum = math.pow(x, i)+math.pow(y, j)
                sum = int (sum)
                if sum <= bound:
                    if sum not in res:
                        res.append(sum)

               
                if y == 1:
                    break
             
        
            if  x == 1:
                break
            

        return res

注意:要对sum做int处理

y等于1时,容易造成死循环,要结束掉
x等于1时,容易造成死循环,要结束掉