Leetcode 970. Powerful Integers

Brute Force(暴力)

class Solution(object):
    def powerfulIntegers(self, x, y, bound):
        """
        :type x: int
        :type y: int
        :type bound: int
        :rtype: List[int]
        """
        ans=[]
        
        for i in range(20):
            for j in range(20):
                a=x**i+y**j
                if a<=bound:
                    ans.append(a)
        
        return list(set(ans))
原文地址:https://www.cnblogs.com/zywscq/p/10540582.html