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))

 

posted @ 2019-03-16 08:24  周洋  阅读(398)  评论(0编辑  收藏  举报